Sid*_*rth 4 xcode ios swift swift3
我刚刚开始使用Swift(newbie)开发新的应用程序。我有
Navigation Controller两个连接了seguesHome和Registration。ViewController.swift,viewDidLoad我正在决定要调用哪个序列我Main.Storyboard没有rootViewController,我需要决定viewController在运行时显示哪个。
if (Settings.hasRegistrationCompleted()) {
performSegue(withIdentifier: "Home", sender: nil)
} else {
performSegue(withIdentifier: "Registration", sender: nil)
}
Run Code Online (Sandbox Code Playgroud)我的问题
if (Settings.has,但断点从未到达此处编辑
我已将其Main设置为Main Interface我的项目。我进行了Clean构建,然后再试一次,没有用。
下面也是Main.Storyboard
在这里您需要确定两件事
第一
检查你的故事板的名称Main.storyboard是否正确连接在你的Target -> general -> Deployment Info -> main Interface,对于如这样
第二
检查你的INTIAL VC与导航控制器连接,并确保您的初始VC为根控制器
更新答案
初始设定Stroryboard ID和每个VC
有改变的appdelegate根控制器后
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
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2606 次 |
| 最近记录: |