【发布时间】:2015-01-23 01:40:51
【问题描述】:
在 AppDelegate 中,我检查是否存在用户,如果存在,我通过使用以下代码推送 NavigationController 来“跳过”两个 ViewController:
if(currentUser){
self.window = [[UIWindow alloc] initWithFrame:UIScreen.mainScreen.bounds];
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIViewController *viewController = [storyboard instantiateViewControllerWithIdentifier:@"Test"];
self.window.rootViewController = viewController;
viewController.navigationController.navigationBarHidden = NO; // Tried this nothing happened.
[self.window makeKeyAndVisible];
}
else{
[PFUser enableAutomaticUser];
[[PFUser currentUser] incrementKey:@"RunCount"];
[[PFUser currentUser] saveInBackground];
[[PFUser currentUser] fetch];
self.window = [[UIWindow alloc] initWithFrame:UIScreen.mainScreen.bounds];
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UINavigationController *viewController = [storyboard instantiateViewControllerWithIdentifier:@"firstView"];
self.window.rootViewController = viewController;
[self.window makeKeyAndVisible];
}
所以真正的语句跳过两个 ViewController 并推送 UINavigationController。但是当它以这种方式显示时,没有顶栏。
但是,如果没有用户,那么它将通过 segues 以“正常”方式进入 UINavigationController,然后该栏是可见的。
我该如何解决这个问题?
谢谢!
【问题讨论】:
标签: ios objective-c iphone uinavigationcontroller uinavigationbar