我正在使用 Swift2,并在我的应用中使用 Facebook 登录(以 Firebase 作为后端)。在登录屏幕上,一旦用户选择 FB 登录,我想使用一些附加信息更新用户个人资料并将其存储在 Firebase 中。但是到更新一些信息的 Controller 的segue。永远不会出现。日志告诉我 Facebook 帐户信息已正确检索,但此继续
self.performSegueWithIdentifier("completeProfile", sender: nil)
从来没有工作过。我在 segue 上设置了正确的标识符。
@IBAction func facebookLogin(sender: AnyObject) {
AppUtility.loginWithFacebook { (success) in
if success {
AppUtility.getUserData({ (success) in
if success {
ApplicationDelegate.showTabBarController()
}
else {
print ("Attempting FB Login - 5 ")
self.performSegueWithIdentifier("completeProfile", sender: nil)
print ("Attempting FB Login - 6 ")
}
})
}
}
}
有趣的是,这可以显示转场:
@IBAction func facebookLogin(sender: AnyObject) {
AppUtility.loginWithFacebook { (success) in
self.performSegueWithIdentifier("completeProfile", sender: nil)
if success {
AppUtility.getUserData({ (success) in
if success {
ApplicationDelegate.showTabBarController()
}
else {
print ("Attempting FB Login - 5 ")
print ("Attempting FB Login - 6 ")
}
})
}
}
}
最佳答案
您应该将其放在成功案例中,如下所示:
@IBAction func facebookLogin(sender: AnyObject) {
AppUtility.loginWithFacebook { (success) in
if success {
AppUtility.getUserData({ (success) in
if success {
self.performSegueWithIdentifier("completeProfile", sender: nil)
ApplicationDelegate.showTabBarController()
}
else {
print ("Attempting FB Login - 5 ")
print ("Attempting FB Login - 6 ")
}
})
}
}
但是我不确定您是否希望 showTabBarController 在同一个 block 中。
关于swift - segue 无法在登录屏幕上工作以更新 swift 中的个人资料,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40429689/