Black TabBar on iOS5 device

僤鯓⒐⒋嵵緔 提交于 2019-12-11 22:41:21

问题


if I run my app under iOS5 all seems to be fine. But if I try to load a view with a TabBar and some views in it.

The screen looks actually like the picture below, so a black tabbar and the first subview of the tabbar which should be onscreen is deallocated. I assume, that the binding between the view and the tabbar does not exist.

So I think it has something to do how I link the views with the tabbar.

It works like that:

NSMutableArray* controllersForHome = [[self.tabBarController.viewControllers mutableCopy] autorelease];
[controllersForHome insertObject:somveViewController atIndex:[controllersForHome count]];
[self.tabBarController setViewControllers:controllersForHome];
[someViewController release];

I've read that inserting the object at an index >0 should be helpful, but unfortunately not in my case. Still the same issue.

Has somebody a guess and can give me a hint how to solve that problem?

Thanks,

Andreas


回答1:


this is how I solved the problem in iOS 5:

Instead of using this:

SMutableArray* controllersForHome = [[self.tabBarController.viewControllers mutableCopy] autorelease];

[controllersForHome insertObject:someViewController atIndex:[controllersForHome count]];

[self.tabBarController setViewControllers:controllersForHome];
[someViewController release];

You should use this:

self.tabBarController.viewControllers = [[NSArray arrayWithArray:self.tabBarController.viewControllers] arrayByAddingObject:someViewController];


来源:https://stackoverflow.com/questions/7847911/black-tabbar-on-ios5-device

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!