我有点卡住,并会明白我做错了什么想法。 我编程方式创建一个NSObject的,其持有的UITabBarController向其中添加了三个ViewControllers:UITabBarController加载子视图
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];'
我现在显示tabBarController的观点
viewController.modalTransitionStyle = transitionStyle;
[self presentModalViewController:viewController animated:YES];
用的viewController作为刚刚创建tabBarController。 视图正常变化,正确显示标签栏(图标和标题),但未能显示例如OneViewController的视图。我假设视图未被加载,因为- (void)viewDidLoad
没有被任何子视图控制器调用。
我将不胜感激任何建议。
感谢, 球菌
笔尖名称为OneView.xib,TwoView.xib和ThreeView.xib。据我所知,我不需要在使用'initWithNibName'时提供文件结尾。但是我只是用_.xib_文件扩展名尝试了它,并没有加载。 – equinox 2011-04-17 07:19:37
我已经尝试过你正在尝试做什么而没有任何问题。所以,也许你可以发布更多的代码,比如ControllerOne和所有你的ivar和属性声明。 – Jamie 2011-04-17 09:37:14