如何将同一个实例的多个控制器添加到我的tabBarController中?

时间:2012-10-29 07:55:16

标签: iphone objective-c ios cocoa

我想添加多个与我的tabBarController相同实例的控制器。但我不能。添加的数组控制器被视为一个控制器。我该怎么办?最好的方法是什么?这是我的代码。

RootViewController *rootViewController = [[[RootViewController alloc]init]autorelease];
tabBarController = [[[UITabBarController alloc]init]autorelease];
[tabBarController setDelegate:self];
[tabBarController setViewControllers:[NSArray arrayWithObjects:rootViewController,rootViewController,rootViewController,rootViewController,rootViewController,nil] animated:NO];

1 个答案:

答案 0 :(得分:1)

你可以试试这个:

RootViewController *rootViewController = [[[RootViewController alloc]init]autorelease];
RootViewController *rootViewController2 = [rootViewController retain];
RootViewController *rootViewController3 = [rootViewController retain];

tabBarController = [[[UITabBarController alloc]init]autorelease];
[tabBarController setDelegate:self];
    [tabBarController setViewControllers:[NSArray arrayWithObjects:rootViewController, rootViewController2, rootViewController3, nil] animated:NO];