使用FB SDK登录后,我想跳到仪表板。我可以登录并已经登录。但我无法跳至仪表板。有什么问题?

非常感谢你

ViewController类:UIViewController,FBSDKLoginButtonDelegate {

override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view, typically from a nib.

    // login button

    let loginButton = FBSDKLoginButton()
    view.addSubview(loginButton)

    loginButton.frame = CGRect(x: 16, y: 500, width: view.frame.width - 40, height: 50)

    // getting login status back

    loginButton.delegate = self

    // if login then head to dashboard

    if FBSDKAccessToken.current() == nil {
        // User is not already logged
        print("No Logged")
    } else {
        // User is already logged
        fetchProfile()
        print("Already Logged")
    }
}

func loginButton(_ loginButton: FBSDKLoginButton!, didCompleteWith result: FBSDKLoginManagerLoginResult!, error: Error!) {
    if error != nil {
        print(error)
        return
    }
    // jump to Dashboard

    performSegue(withIdentifier: "goToDashboard", sender: self)
    print("logged in")
}

func loginButtonDidLogOut(_ loginButton: FBSDKLoginButton!) {
    print("logged out")
}


}

最佳答案

performSeague在这里不起作用。

这是我正在使用的另一种方法

func jumpToDashboard() {
    let next = storyboard?.instantiateViewController(withIdentifier: "Dashboard")
    self.present(next!, animated: true, completion: nil)
}

09-17 14:01