gpt4 book ai didi

ios - 将新的 View Controller 链接到 Storyboard?

转载 作者:IT王子 更新时间:2023-10-29 07:51:31 26 4
gpt4 key购买 nike

可能有一个简单的解决方案,但我想不出来。

我正在为界面使用 Storyboard。

我从标签栏 Controller 开始,但在允许用户使用该应用程序之前,用户必须通过在开始时以模态方式推送的登录 View 来验证自己。

我想在同一个 Storyboard 中配置登录 View ,但我不知道如何链接 Storyboard 中的 View Controller 和我的代码。

我做了什么:

  • 通过 file > new > new file 创建一个新的 UIViewController 子类。
  • 在 Storyboard中拖动一个新的 UIViewController
  • 在自定义类选项卡中设置类
  • 为测试目的拖一个 UILabel。
  • 运行

没有标签...

最佳答案

拉入一个新的 UIViewController,它将充当 MainStoryboard 上的登录 View Controller 。在属性检查器中,将标识符更改为 LoginViewController(或适当的东西)。然后添加

- (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];
}

到第一个 View Controller ,登录屏幕将从您的 Storyboard加载并呈现。

希望这对您有所帮助。

关于ios - 将新的 View Controller 链接到 Storyboard?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7978932/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com