ios - LaunchScreen.storyboard 未打开 Main.storyboard 导航 Controller

标签 ios swift xcode swift3

我刚刚开始使用 Swift(新手)开发一个新应用程序。我有

  1. Lau​​nchScreen.storyboard 仅包含我的初始屏幕图像
  2. 我有一个带有 Navigation Controller 的 Main.storyboard 连接到两个 segues,Home 和 Registration。
  3. ViewController.swift 中,在 viewDidLoad 中,我决定调用哪个 segue
  4. 我的Main.Storyboard 没有rootViewController,我需要决定在运行时显示哪个viewController时间

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

我的问题

  1. 我在第一行设置了一个断点if (Settings.has 并且断点永远不会到达这里
  2. Lau​​nchScreen 只持续 2 秒(在我的模拟器上测试)如何增加它

编辑

我在我的项目中将 Main 设置为 Main Interface。我做了一个 Clean 构建并再次尝试,但没有成功。

下面还有Main.Storyboard

enter image description here

最佳答案

这里有两件事你需要确定

首先

检查你的 Storyboard名称 Main.storyboard 是否正确附加在你的 Target -> general -> Deployment Info -> main Interface 中,例如像这样

enter image description here

第二个

检查你的Intial VC连接到navigation Controller,确保你的Initial VC是Root controller

enter image description here

更新答案

初始设置 Storyboard ID 并为每个 VC

enter image description here

在 appdelegate 中更改 Root Controller 之后

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
}

关于ios - LaunchScreen.storyboard 未打开 Main.storyboard 导航 Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42665290/

相关文章:

iphone - Xcode错误语义错误值可能无法响应 'initWithFrame:image Name:'

swift - UICollectionView 不显示图像

ios - Swift Advanced - 在运行时设置扩展

ios - 以编程方式更改 Y 位置约束

ios - 电子邮件链接验证不工作 : Firebase Auth always returns false for `isSignIn(withEmailLink:)`

swift - 无法将加密数据转换为字符串

xcode - ARM NEON 汇编程序错误 : "instruction cannot be conditional"

ios - 本地通知在 iOS 10.3.1 中不起作用

ios - layoutIfNeeded 导致崩溃

Swift Vapor Postgres Xcode 构建错误 : Could not build Objective-C module 'CPostgreSQLMac'