【问题标题】:Moving to one storyboard to another via a class通过类移动到一个故事板到另一个故事板
【发布时间】:2017-05-14 11:25:39
【问题描述】:

我在第一个视图控制器中有 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];

【问题讨论】:

    标签: ios uiviewcontroller storyboard


    【解决方案1】:

    用你当前的 navigationController 展示它:

    [self.navigationController pushViewController: viewController animated: NO];
    

    或者从当前的 VC 展示它:

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

    【讨论】:

    • 类与viewcontroller没有关系,所以没有导航控制器
    【解决方案2】:

    您必须将 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;
    

    【讨论】:

      猜你喜欢
      • 2014-11-13
      • 2013-09-17
      • 2017-01-04
      • 2017-02-22
      • 2012-03-23
      • 1970-01-01
      • 2014-04-29
      • 1970-01-01
      • 2013-02-03
      相关资源
      最近更新 更多