我想知道为什么我的代码无法正常工作,我在 this video 中遵循的位置。它总是不断抛出此错误:
Thread 1: signal SIGABRT.
我是 Swift 和 iOS 开发新手。
抛出错误:
self.presentViewController(homeViewController, animated: true, completion: nil)
代码:
FIRAuth.auth()?.addAuthStateDidChangeListener { auth, user in
if let user = user {
let mainStoryboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let homeViewController: UIViewController = mainStoryboard.instantiateViewControllerWithIdentifier("HomeView")
self.presentViewController(homeViewController, animated: true, completion: nil)
} else {
self.loginButton.center = self.view!.center
self.loginButton.readPermissions = ["public_profile", "email", "user_friends"]
self.loginButton.delegate = self
self.view!.addSubview(self.loginButton)
self.loginButton.hidden = false
}
}
最佳答案
首先转到您的 main.storyboard 并检查您的 Storyboard Segue 的命名是否正确,其中一个应命名为“HomeView”。
然后尝试清洁您的产品(SHIFT + CMD + A 或“产品 --> 清洁”)。
希望这能起作用。
关于ios - swift “线程1 : Signal SIGABRT in PresentViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40297125/