我无法让setViewControllers为我的UITabBarController
设置视图控制器。
在我的UITabBarController
子类的实现中,我有:
- (void)viewDidLoad
{
[super viewDidLoad];
self.navigationItem.title = @"Test";
self.navigationItem.backBarButtonItem.title = @"To Test";
NSMutableArray *aViewControllersArray = [[NSMutableArray alloc] initWithCapacity:2];
UINavigationController* aNavigationController;
aNavigationController = [UIViewControllerOne alloc];
[aViewControllersArray addObject:aNavigationController];
[aNavigationController release];
aNavigationController = [UIViewControllerTwo alloc];
[aViewControllersArray addObject:aNavigationController];
[aNavigationController release];
[self setViewControllers:aViewControllersArray animated:TRUE];
[aViewControllersArray release];
}
aViewControllersArray有两个UIViewControllers
,但UITabBarController
的viewControllers属性为nil。
我做错了什么?
答案 0 :(得分:0)
想出来:
在创建我的UITabBarController时,我一直在做
[MyUITabBarController alloc]
而不是
[[MyUITabBarController alloc] init]
添加init
节省了一天。