开发者

adding a uinavbaritem across all views

开发者 https://www.devze.com 2023-03-22 07:38 出处:网络
I have a uitabbarcontroller with uinavigation controller for 2 view controllers. i am trying to have a uinavigationitem (something like \"settings\" that exist in most of the apps). I am wondering if

I have a uitabbarcontroller with uinavigation controller for 2 view controllers. i am trying to have a uinavigationitem (something like "settings" that exist in most of the apps). I am wondering if I need to define this item in every view (tabOneViewController, tabTwoViewController, etc.), or is there a global way to define this buttons so it will stay when I开发者_开发知识库 move between different tabs?

here is how I create my tab/nav controllers in my 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];
0

精彩评论

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