将新的视图控制器链接到故事板? [英] Linking a new viewcontroller to Storyboard?

查看:22
本文介绍了将新的视图控制器链接到故事板?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能有一个简单的解决方案,但我无法弄清楚.

There is probably a simple solution but I can't figure it out.

我在界面上使用故事板.

I am using storyboards for the interface.

我从标签栏控制器开始,但在允许用户使用应用程序之前,用户必须通过在开始时模态推送的登录视图对自己进行身份验证.

I start with a tab bar controller, but before the user is allowed to use the app the user has to authenticate himself trough a loginview which is modally pushed at the start.

我想在同一个故事板中配置登录视图,但我无法弄清楚如何将故事板中的视图控制器和我的代码链接起来.

I want to configure the loginview at the same storyboard, but I can't seam to figure out how to link the view controller at the storyboard and my code.

我做了什么:

  • 创建一个新的 UIViewController 子类槽文件 > 新建 > 新文件.
  • 在故事板中拖出一个新的 UIViewController
  • 在自定义类选项卡中设置类
  • 拖动 UILabel 以进行测试.
  • 运行

没有标签...

推荐答案

拉入一个新的 UIViewController,它将作为 MainStoryboard 上的登录视图控制器.在属性检查器中,将标识符更改为 LoginViewController(或适当的东西).然后添加

Pull on a new UIViewController that will act as the login view controller onto the MainStoryboard. In the attribute inspector change the identifier to LoginViewController (or something appropriate). Then add

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];

    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
    UIViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"LoginViewController"];
    [vc setModalPresentationStyle:UIModalPresentationFullScreen];

    [self presentModalViewController:vc animated:YES];
}

到第一个视图控制器,登录屏幕将从您的故事板加载并呈现.

to the First view controller and the login screen will be loaded from your storyboard and presented.

希望这会有所帮助.

这篇关于将新的视图控制器链接到故事板?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆