通过课程转移到另一个故事板

时间:2016-12-30 06:13:46

标签: ios uiviewcontroller storyboard

我在第一个viewcontroller中有2个故事板当前控制器到达。我想通过课程移动到第二个故事板

UIStoryboard * storyboard=[UIStoryboard storyboardWithName:@"CMS_OrganisationManagement" bundle:nil];
                                   UIViewController *viewcontroller=[storyboard instantiateViewControllerWithIdentifier:@"WS_OrganisationSelectViewController"];
                                   UIWindow *window;
                                   window.rootViewController = viewcontroller;

它没有用 我也尝试这种方法。它也不起作用

UIStoryboard * storyboard=[UIStoryboard storyboardWithName:@"CMS_OrganisationManagement" bundle:nil];
                                   UIViewController *viewcontroller=[storyboard instantiateViewControllerWithIdentifier:@"WS_OrganisationSelectViewController"];
                                   UINavigationController * navigationController=[[UINavigationController alloc]init];
                                   [navigationController pushViewController:viewcontroller animated:YES];

2 个答案:

答案 0 :(得分:0)

使用您当前的navigationController:

显示它
[self.navigationController pushViewController: viewController animated: NO];

或者从当前的VC中提出它:

[self presentViewController: viewController animated: YES completion: nil];

答案 1 :(得分:0)

您必须将navigationController添加为rootViewController

 UIStoryboard * storyboard=[UIStoryboard storyboardWithName:@"CMS_OrganisationManagement" bundle:nil];
 UIViewController *viewcontroller=[storyboard instantiateViewControllerWithIdentifier:@"WS_OrganisationSelectViewController"];
 UINavigationController *NC = [[UINavigationController alloc] initWithRootViewController:viewcontroller];
 UIWindow *window;
 window.rootViewController = NC;