导航条不显示presentViewController后

问题描述:

嗨那里我用这个代码移动到新的contorller只是与代码和不segue。导航条不显示presentViewController后

UIStoryboard * mainstoryb = [UIStoryboard storyboardWithName:@"Main" bundle:nil]; 
UIViewController * vc = [mainstoryb instantiateViewControllerWithIdentifier:@"online_shop"]; 
[self presentViewController:vc animated:YES completion:nil]; 

如何在下一个视图上显示导航栏或标题栏?

需要出示NavigationController如下:

UIViewController *vc = [self.storyboard instantiateViewControllerWithIdentifier:ContactUSVCID]; 
UINavigationController *objNav = [[UINavigationController alloc] initWithRootViewController:vc]; 
[self presentViewController:objNav animated:YES completion:nil]; 

如果你想要的导航栏,那么你推不存在

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:storyboardName bundle: nil]; 


     SecondViewController * vc = [storyboard instantiateViewControllerWithIdentifier:@"ViewControllerB"]; 
    /********if dont have navigation bar***********/ 
UINavigationController *initialNavigationController = (UINavigationController*)[self.storyboard instantiateViewControllerWithIdentifier:@"HomeNavCtrl_id"]; 
[self presentViewController:initialNavigationController animated:YES completion:nil]; 

/**********其他*************/

[[self navigationController] pushViewController:vc animated:YES]; 

中嵌入导航控制器和故事板ID您的ViewController导航控制然后使用此代码

UINavigationController *initialNavigationController = (UINavigationController*)[self.storyboard instantiateViewControllerWithIdentifier:@"HomeNavCtrl_id"]; 
[self presentViewController:initialNavigationController animated:YES completion:nil]; 

如果您提供视图控制器,它将始终以全屏显示。 试试这个

UIStoryboard * mainstoryb = [UIStoryboard storyboardWithName:@"Main" bundle:nil]; 
UIViewController * vc = [mainstoryb instantiateViewControllerWithIdentifier:@"online_shop"]; 
[self presentViewController:navigationController animated:YES completion:nil];