我刚刚开始使用 Swift(新手)开发一个新应用程序。我有
- LaunchScreen.storyboard 仅包含我的初始屏幕图像
- 我有一个带有
Navigation Controller
的 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) }
我的问题
- 我在第一行设置了一个断点
if (Settings.has
并且断点永远不会到达这里 - LaunchScreen 只持续 2 秒(在我的模拟器上测试)如何增加它
编辑
我在我的项目中将 Main
设置为 Main Interface
。我做了一个 Clean
构建并再次尝试,但没有成功。
下面还有Main.Storyboard
最佳答案
这里有两件事你需要确定
首先
检查你的 Storyboard名称 Main.storyboard
是否正确附加在你的 Target -> general -> Deployment Info -> main Interface
中,例如像这样
第二个
检查你的Intial VC连接到navigation Controller,确保你的Initial VC是Root controller
更新答案
初始设置 Storyboard ID 并为每个 VC
在 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/