View Loading Problem
I am using some xib without tab bar and some with tab bar.
In starting i load the xib without tab bar-navigation bar then flow ar开发者_JAVA技巧e working.But if i load a xib with tab bar-navigation bar then our all view slide bellow and half tab bar are not showing.Please anybody help me as soon as possible.
Pleaseeee!!!!!!
Are you loading a Tab Bar Controller or just a single Tab Bar? Is it happening right after pushing a view with a Navigation Controller? If so, the same happened to me (link here) and I have been unable to fix it. I think that it's something not supported and not recommended by Apple, you can find this in the NavigationController Class Reference:
- viewController: The view controller that is pushed onto the stack. This object cannot be an instance of tab bar controller and it must not already be on the navigation stack.
What I did was to add a single Tab Bar (not a Tab Bar Controller) to the view that is being pushed, and then configure it programmatically. You can find a very good example in here (http://discussions.apple.com/thread.jspa?threadID=2099944&tstart=0), but it would be something like this:
- (void)activateTab:(int)index {
switch (index) {
case 1:
if (tab1ViewController == nil) {
self.tab1ViewController =
[[Tab1ViewController alloc] initWithNibName:@"Tab1View" bundle:nil];
}
[self.view addSubview:tab1ViewController.view];
if (currentViewController != nil)
[currentViewController.view removeFromSuperview];
currentViewController = tab1ViewController;
break;
case 2:
if (tab2ViewController == nil) {
self.tab2ViewController =
[[Tab2ViewController alloc] initWithNibName:@"Tab2View" bundle:nil];
}
[self.view addSubview:tab2ViewController.view];
if (currentViewController != nil)
[currentViewController.view removeFromSuperview];
currentViewController = tab2ViewController;
break;
default:
break;
}
}
- (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item {
[self activateTab:item.tag];
}
- (void)viewDidLoad {
[super viewDidLoad];
[myTabBar setSelectedItem:[myTabBar.items objectAtIndex:0]];
[self activateTab:1];
}
Of course you would need to declare your Tab Bar as well that the three View Controllers that are in use here (tab1ViewController, tab2ViewController and currentVideoController).
You don't give much details, but I hope this can help a little bit.
精彩评论