2

我想将多个相同实例的控制器添加到我的 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];
4

1 回答 1

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];
于 2012-10-29T07:59:46.920 回答