你的代碼是好的,在同一時間,你需要實現performSegueWithIdentifier
對於SEGUE
use segue identifier in Push Method and give the proper connection
如果您正在使用Identifier
,然後調用這一行,其中u需要 self.performSegueWithIdentifier( 「identifierName」,發送方:自)
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)
}
}
最簡單的方法,在storyboar中添加一個segue d,分配一個標識符,然後調用'performSegueWithIdentifier' – zcui93