【问题标题】:Load UISplitViewController programmatically from another Storyboard从另一个 Storyboard 以编程方式加载 UISplitViewController
【发布时间】:2013-08-09 15:51:50
【问题描述】:

目前我在我的项目中使用了两个 iPad 故事板。

第一个故事板有一个登录屏幕和一个表格视图控制器。当单击单元格时,我想从第一个故事板 tableview 控制器调用第二个故事板。通常这很容易,但这里的第二个故事板有一个UISplitViewController

    MainSVC *baseView = [[MainSVC alloc] init]; //UISplitViewController

    UIStoryboard *storyBoard=[UIStoryboard storyboardWithName:@"Mail_iPad" bundle:nil]; //Second Storyboard

    baseView =[storyBoard instantiateViewControllerWithIdentifier:@"MainSVC"]; //MainSVC = Storyboard Name
    [self presentViewController:baseView animated:YES completion:nil];

此代码不起作用。我在谷歌搜索,但找不到最佳解决方案。

如何以编程方式调用第二个故事板拆分视图控制器?

【问题讨论】:

    标签: ios objective-c ipad storyboard uisplitviewcontroller


    【解决方案1】:

    使用此代码。这应该是工作。 !

        UIStoryboard *storyBoard=[UIStoryboard storyboardWithName:@"Mail_iPad" bundle:nil];
    
        UISplitViewController *split = [storyBoard instantiateViewControllerWithIdentifier:@"MainSVC"];
        self.view.window.rootViewController = split;
    

    【讨论】:

      【解决方案2】:

      不要分配另一个拆分视图控制器实例。应该是这样的

      UIStoryboard *storyBoard=[UIStoryboard storyboardWithName:@"Mail_iPad" bundle:nil]; //Second Storyboard
      
      MainSVC *baseView =(MainSVC *)[storyBoard instantiateViewControllerWithIdentifier:@"MainSVC"]; //MainSVC = Storyboard Name
      [self presentViewController:baseView animated:YES completion:nil];
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-02-19
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多