开发者

UITabBarController to load subviews

I am kind of stuck and would appreciate any ideas on what I did wrong. I created programmatically a NSObject which holds a UITabBarController to which three ViewControllers are added:

UITabBarController tabBarController = [[UITabBarController alloc] init];

ControllerOne = [[OneViewController alloc] initWithNibName:@"OneView" bundle:nil];     
ControllerTwo = [[TwoViewController alloc]initWithNibName:@"TwoView" bundle:nil];   
ControllerThree = [[ThreeViewController alloc] initWithNibName:@"ThreeView" bundle:nil];  
NSMutableArray *viewControllers = [[NSMutableArray alloc] initWithCapacity:3];
[viewControllers addObject:ControllerOne];
[viewControllers addObject:ControllerTwo];
[viewControllers addObject:ControllerThree];
[tabBarController setViewControllers:viewControllers];'

I now display the tabBarController's view

 viewController.modalTransitionStyle = transitionStyle;
[self presentModalViewController:viewController animated:YES];

with viewController being the just created tabBarController. Th开发者_开发问答e view changes fine, displaying the tabbar correctly (Icons and titles) but fails to show e.g. OneViewController's view. I assume that the view is not loaded since the - (void)viewDidLoad is not being called for any of the subview controllers.

I would appreciate any suggestions.

Thanks, equi


Are you sure your nib names are how you have typed them? It's not called OneViewController.xib?, for example?


I sorted out the issue. The above code actually worked, reason for the view not appearing was that I accidentally synthesised 'view' in the UIViewController derivative.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜