我想知道为什么我的代码无法正常工作,我在this video的哪个地方。它总是不断抛出这个错误:
线程1:信号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并检查你的故事板segues是否正确命名,应该命名为“HomeView”。
然后尝试清洁您的产品(SHIFT + CMD + A或'产品 - >清洁')。
希望这有效。
抱歉,我认为Cocoa touch选项中缺少UIViewController。所以,我通过将子类更改为UIViewController而不是UITableViewController来修复。