加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ios – LaunchScreen.storyboard无法打开Main.storyboard导航控

发布时间:2020-12-14 17:51:01 所属栏目:百科 来源:网络整理
导读:我刚刚开始使用 Swift(新手)开发一个新的应用程序.我有 LaunchScreen.storyboard只有我的启动画面的图像 我有一个Main.storyboard,导航控制器连接到两个segues,Home和Registration. 在ViewController.swift中,在viewDidLoad中我决定调用哪个segue 我的Main.S
我刚刚开始使用 Swift(新手)开发一个新的应用程序.我有

> LaunchScreen.storyboard只有我的启动画面的图像
>我有一个Main.storyboard,导航控制器连接到两个segues,Home和Registration.
>在ViewController.swift中,在viewDidLoad中我决定调用哪个segue
>我的Main.Storyboard没有rootViewController,我需要决定在运行时显示哪个viewController.

if (Settings.hasRegistrationCompleted()) {
    performSegue(withIdentifier: "Home",sender: nil)
} else {
    performSegue(withIdentifier: "Registration",sender: nil)
}

我的问题

>如果(Settings.has和断点永远不会到达此处),我会在第一行放置一个断点
> LaunchScreen仅持续2秒(在我的模拟器上测试)如何增加它

编辑

我将Main设置为我项目的主界面.我做了一个Clean build并再次尝试,但没有工作.

以下是Main.Storyboard

enter image description here

解决方法

在这里你需要识别两件事

第一

检查您的故事板名称Main.storyboard是否正确附加在您的目标中 – >一般 – >部署信息 – >主接口,例如像这样

enter image description here

第二

检查与导航控制器连接的初始VC并确保初始VC为根控制器

enter image description here

更新答案

最初为每个VC设置Stroryboard ID

enter image description here

在appdelegate中更改Root控制器之后

func application(_ application: UIApplication,didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    self.window = UIWindow(frame: UIScreen.main.bounds)
    // Override point for customization after application launch.
     let storyboard = UIStoryboard(name: "Main",bundle: nil)
    let rootViewController: UIViewController?
     if (Settings.hasRegistrationCompleted()) {
     rootViewController = storyboard.instantiateViewController(withIdentifier: "HomeVC")
    }else
     {
         rootViewController = storyboard.instantiateViewController(withIdentifier: "RegistrationVC")
    }
     let navigation = UINavigationController(rootViewController: rootViewController!)
    self.window?.rootViewController = navigation
    self.window?.makeKeyAndVisible()
    return true
}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读