将新的视图控制器链接到情节提要?

Linking a new viewcontroller to Storyboard?(将新的视图控制器链接到情节提要?)

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

问题描述

可能有一个简单的解决方案,但我想不通.

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.

希望这会有所帮助.

这篇关于将新的视图控制器链接到情节提要?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:将新的视图控制器链接到情节提要?

基础教程推荐