寻找新视图控制器

时间:2016-03-21 15:29:55

标签: ios swift ios9 segue

所以我使用视图controller.swift文件中的以下内容在我的应用程序中实现了FB登录

func loginButton(loginButton: FBSDKLoginButton!, didCompleteWithResult result: FBSDKLoginManagerLoginResult!, error: NSError!) {

    if error == nil
    {
        print("Login Successful")
    }
    else
    {
        print(error.localizedDescription)
    }

}

从这一点来看,虽然我不确定在成功登录后如何/在哪里调用函数segue,但我是swift的新手,所以任何详细的解释都会很棒。

2 个答案:

答案 0 :(得分:0)

在storyboard中的视图控制器之间声明segue在属性检查器中设置标识符,例如“showNexController”并执行此操作:

final

答案 1 :(得分:0)

您的代码很好,同时您需要为segue

实施performSegueWithIdentifier

enter image description here

use segue identifier in Push Method and give the proper connection

如果您使用Identifier,请在您需要的地方拨打此行     self.performSegueWithIdentifier(" identifierName",sender: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

例如

I have given segue identifier in SeconViewController as in the image.

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)
    }

}