问题
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