【问题标题】:Connect StoryBoard Button with Programmatically build UITabBarController将 StoryBoard 按钮与以编程方式构建的 UITabBarController 连接
【发布时间】:2018-03-15 21:51:06
【问题描述】:

我建了两个项目

  1. 故事板 -> 登录屏幕
  2. 以编程方式 -> UITabBarController

两者都是不同的项目,但使用 MVC 结构进行管理 现在我想将 StoryBoard Button 与以编程方式构建的 UITabBarController 连接 请帮我解决这个问题。

【问题讨论】:

    标签: ios swift3 xcode8 ios10


    【解决方案1】:

    创建视图控制器:

    UIViewController * vc = [[UIViewController alloc] init];
    

    调用视图控制器(必须从另一个视图控制器中调用):

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

    首先,使用 nil 而不是 null。

    从情节提要加载视图控制器:

    NSString * storyboardName = @"MainStoryboard"; 
    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:storyboardName bundle: nil];
    UIViewController * vc = [storyboard instantiateViewControllerWithIdentifier:@"IDENTIFIER_OF_YOUR_VIEWCONTROLLER"];
    [self presentViewController:vc animated:YES completion:nil];
    

    您的视图控制器的标识符等于您的视图控制器的类名,或者您可以在情节提要的身份检查器中分配的情节提要 ID。

    【讨论】:

      猜你喜欢
      • 2018-12-04
      • 2013-11-08
      • 1970-01-01
      • 2012-12-11
      • 1970-01-01
      • 2011-12-24
      • 1970-01-01
      • 1970-01-01
      • 2018-06-14
      相关资源
      最近更新 更多