我想添加多个与我的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];
答案 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];