因此,我使用 viewcontroller.swift 文件中的以下内容实现了 FB 登录到我的应用程序
func loginButton(loginButton: FBSDKLoginButton!, didCompleteWithResult result: FBSDKLoginManagerLoginResult!, error: NSError!) {
if error == nil
{
print("Login Successful")
}
else
{
print(error.localizedDescription)
}
}
从这一点来看,虽然我不确定如何/在哪里调用函数来在成功登录后进行继续,但我对 swift 很陌生,所以任何详细的解释都会很棒。
最佳答案
你的代码没问题,同时你需要为segue实现performSegueWithIdentifier
use segue identifier in Push Method and give the proper connection
如果您使用Identifier
,请在您需要的地方调用此行
self.performSegueWithIdentifier("identifierName", 发件人: self)
func loginButton(loginButton: FBSDKLoginButton!, didCompleteWithResult result: FBSDKLoginManagerLoginResult!, error: NSError!) {
if error == nil
{
print("Login Successful")
self.performSegueWithIdentifier("identifierName", sender: self)
}
else
{
print(error.localizedDescription)
}
}
选择2
if use `storyboard ID` with connection less
例如
func loginButton(loginButton: FBSDKLoginButton!, didCompleteWithResult result: FBSDKLoginManagerLoginResult!, error: NSError!) {
if error == nil
{
print("Login Successful")
let second = self.storyboard?.instantiateViewControllerWithIdentifier("SecondViewControllerSegue") as? SecondViewController
self.navigationController?.pushViewController(second!, animated: true)
}
else
{
print(error.localizedDescription)
}
}
关于ios - 转至新的 View Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36135229/