以下代码适用于ipad,但不适用于iphone。
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main_iPhone" bundle:nil];
UIViewController *controller = (UIViewController *)[storyboard instantiateViewControllerWithIdentifier:@"MoreAppsViewController"];
UINavigationController *navgiate = [[UINavigationController alloc]initWithRootViewController:controller];
[self.navigationController pushViewController:navgiate animated:YES];
我无法通过安装来加载MoreApsviewController
。 View Controller没有推动请帮我怎么做。在此先感谢
答案 0 :(得分:1)
如果您的容器是导航控制器,您可以简单地使用VC并像这样推送它;
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main_iPhone" bundle:nil];
UIViewController *controller = (UIViewController *)[storyboard instantiateViewControllerWithIdentifier:@"MoreAppsViewController"];
//No need to create a nav controller here
[self.navigationController pushViewController:controller animated:YES];
如果您想添加另一个导航控制器,您可以将其显示或添加为子VC,但是您无法推送另一个导航VC。
答案 1 :(得分:0)
应检查这两个步骤。
如果您尝试访问的View Controller嵌入在导航控制器中,则引用正确的视图是正确的,否则,请将UINavigationController *navgiate
更改为UIViewController * navigate
(或者如果UITableViewController *导航,则这是一个表格视图。
检查视图控制器的引用。如果您的名称为(UIViewController *)[storyboard instantiateViewControllerWithIdentifier:@"MoreAppsViewController"];
,我将假设您已将视图控制器命名为MoreAppsViewController
。您需要将UINavigationController命名为 并引用 ,因为它是参考点。
这是View Controller的结果:
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main_iPhone" bundle:nil];
UIViewController *controller = (UIViewController *)[storyboard instantiateViewControllerWithIdentifier:@"MoreAppsViewController"];
[self.navigationController pushViewController:controller animated:YES];
这是导航控制器的结果:
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main_iPhone" bundle:nil];
//You need to name your Navigation Controller "MoreAppsViewController" for this to work
UINavigationController *controller = (UINavigationController *)[storyboard instantiateViewControllerWithIdentifier:@"MoreAppsViewController"];
[self.navigationController pushViewController:controller animated:YES];