我知道我可以做到这一点
[self.navigationController pushViewController:self.someUITabBarController animated:YES];
这意味着UITabBarController
以某种方式navigationgController
如果我希望someUITabBarController
成为navigationController
的第一个控制器(位于最低级别的控制器),该怎么办?
我无法将rootViewController
的{{1}}更改为NavigationController
答案 0 :(得分:2)
嗯,不确定这是你想要的。此代码下方将放在您“appDelegate”类中的- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
下。
UITabBarController *tabController = [[UITabBarController alloc] init];
UIViewController *viewController1 = ...
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:viewController1];
NSArray *controllers = [NSArray arrayWithObjects:navigationController, nil]; // can add more if you want
[tabController setViewControllers:controllers];
// this is for custom title and image in the tabBar item
navigationController.tabBarItem.title = @"abc";
[navigationController.tabBarItem setImage:[UIImage imageNamed:@"abc.png"]];
self.window.rootViewController = tabController; // or [self.window addSubview: tabController.view];
[self.window makeKeyAndVisible];
答案 1 :(得分:1)
我不确定这是否有效。但试试这个,
UINavigationController *navCont = [[UINavigationController alloc] init];
[navCont pushViewController:navCont animated:NO];