您好,我使用此代码只需使用代码并且没有segue就可以进入新的控制器。
UIStoryboard * mainstoryb = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIViewController * vc = [mainstoryb instantiateViewControllerWithIdentifier:@"online_shop"];
[self presentViewController:vc animated:YES completion:nil];
如何在下一个视图中显示导航栏或标题栏?
答案 0 :(得分:4)
您需要按如下方式呈现NavigationController:
UIViewController *vc = [self.storyboard instantiateViewControllerWithIdentifier:ContactUSVCID];
UINavigationController *objNav = [[UINavigationController alloc] initWithRootViewController:vc];
[self presentViewController:objNav animated:YES completion:nil];
答案 1 :(得分:2)
如果你想要导航栏,那么你必须推不存在
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];
答案 2 :(得分:1)
将导航控制器和故事板ID中的ViewController嵌入导航控制器,然后使用此代码
UINavigationController *initialNavigationController = (UINavigationController*)[self.storyboard instantiateViewControllerWithIdentifier:@"HomeNavCtrl_id"];
[self presentViewController:initialNavigationController animated:YES completion:nil];
答案 3 :(得分:1)
如果您提供视图控制器,它将始终全屏显示。 试试这个
UIStoryboard * mainstoryb = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIViewController * vc = [mainstoryb instantiateViewControllerWithIdentifier:@"online_shop"];
[self presentViewController:navigationController animated:YES completion:nil];