我有一个带有uinavigation控制器的uitabbarcontroller,用于2个视图控制器。我正在尝试使用uinavigationitem(类似于大多数应用程序中存在的“设置”)。我想知道我是否需要在每个视图中定义这个项目(tabOneViewController,tabTwoViewController等),还是有一种全局的方式来定义这个按钮,这样当我在不同的标签之间移动时它会保持不变?
以下是我在AppDelegate中创建标签/导航控制器的方法:
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
UIViewController *viewController1 = [[FirstTab alloc] initWithNibName:@"FirstTab" bundle:NSBundle.mainBundle];
UINavigationController *firstNavController = [[UINavigationController alloc]initWithRootViewController:viewController1];
UIViewController *viewController2 = [[SecondTab alloc] initWithNibName:@"SecondTab" bundle:NSBundle.mainBundle];
UINavigationController *secondNavController = [[UINavigationController alloc]initWithRootViewController:viewController2];
self.tabBarController = [[UITabBarController alloc] init];
self.tabBarController.viewControllers = [NSArray arrayWithObjects:firstNavController, secondNavController, nil];
self.window.rootViewController = self.tabBarController;
[self.window makeKeyAndVisible];