My UITabBarController isn't appearing, but its first view is?
Posted
by E-Madd
on Stack Overflow
See other posts from Stack Overflow
or by E-Madd
Published on 2010-03-11T23:18:11Z
Indexed on
2010/06/01
9:03 UTC
Read the original article
Hit count: 220
I've done some reorganizing of my project recently and now I'm not seeing my tab bar controller, but its first view controller's view is appearing. Here's a breakdown of everything that happens prior to the problem.
App Delegate loads FirstViewController with nib. FirstViewController loads the application data from my server and then presents MainViewController with a modal transition. MainViewController is where the UITabBarController is supposed to be appearing. It's a very simple class.
The .h
@interface MainViewController : UIViewController <UITabBarControllerDelegate> {
IBOutlet UITabBarController *tabBarController;
}
@property (nonatomic, retain) UITabBarController *tabBarController;
@end
The .m
@implementation MainViewController
@synthesize tabBarController;
- (void)viewDidLoad {
NSLog(@"MainViewController viewDidLoad");
//set tab bar controller delegate to self
tabBarController.delegate = self;
// home view
HomeViewController *home = [[HomeViewController alloc] initWithTab];
// menu view
MenuViewController *menu = [[MenuViewController alloc] initWithTab];
// special offers view
SpecialOffersViewController *so = [[SpecialOffersViewController alloc] initWithTab];
// events view
EventsViewController *events = [[EventsViewController alloc] initWithTab];
// info view
InfoViewController *info = [[InfoViewController alloc] initWithTab];
//populate the tab bar controller with view controllers
NSArray *controllers = [NSArray arrayWithObjects:home, menu, so, events, info, nil];
tabBarController.viewControllers = controllers;
//release view controllers
[home release];
[menu release];
[so release];
[events release];
[info release];
[controllers release];
//add tab bar controller to view
[self.view addSubview:tabBarController.view];
[super viewDidLoad];
}
and here's the bit from FirstViewController that modally presents the MainViewController...
MainViewController *controller = [[MainViewController alloc] initWithNibName:@"MainViewController" bundle:nil];
controller.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:controller animated:YES];
[controller release];
I'm not getting any compiler errors or warnings and the app runs swell... no crashing. It just isn't showing the darned TabBar, and it used to when I was creating it on my AppDelegate. I checked everything in my NIB and my outlets seem to be hooked up ok. I have no idea what's happened. Help!
© Stack Overflow or respective owner