开发者

Can't setViewControllers in my UITabBarController

I can't get setViewControllers to set the view controllers for my UITabBarController.

In the implementation for my UITabBarController subclass, I have:

- (void)viewDidLoad
{
    [super viewDidLoad];

    self.navigationItem.title = @"Test";
    self.navigationItem.backBarButtonItem.title = @"To Test";

    开发者_JS百科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];       
}

The aViewControllersArray has the two UIViewControllers, but the viewControllers property of the UITabBarController is nil.

What am I doing wrong?


Figured it out:

In creating my UITabBarController I had been doing

[MyUITabBarController alloc]

rather than

[[MyUITabBarController alloc] init]

Adding init saved the day.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜