简体   繁体   English

prepareForSegue没有打开ViewController

[英]prepareForSegue not opening ViewController

I currently have this code: 我目前有以下代码:

override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
    // Get the new view controller using segue.destinationViewController.
    // Pass the selected object to the new view controller.
    print("Being called: PrepareForSegue")

    if(segue.identifier == "FBLoggedInSegue"){
        print("Identifier: FBLoggedInSegue")
        let nextVC = (segue.destinationViewController as? FBFriendsController)!
        nextVC.accessToken = FBSDKAccessToken.currentAccessToken()
        print("Niks gebeurd")
    }
}

The console actually shows all of the print statements within my if statement. 控制台实际上显示了if语句中的所有print语句。 Unfortunately, the prepareForSegue will not open the FBFriendsController . 不幸的是,prepareForSegue不会打开FBFriendsController

This is the code I am running in the viewDidLoad() function. 这是我在viewDidLoad()函数中运行的代码。

override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view.
    if (FBSDKAccessToken.currentAccessToken() != nil) {
        self.performSegueWithIdentifier("FBLoggedInSegue", sender: self)
    }
}

Make sure you are 100% certain of segue.identifier: Modify print("Identifier: FBLoggedInSegue") to display the actual identifier, otherwise you are working off assumptions. 确保您100%确定segue.identifier:修改print("Identifier: FBLoggedInSegue")以显示实际的标识符,否则,您需要进行假设分析。

Have you set the ID on the view you wish to segue to or or the actual segue line in the Interface Builder? 您设置了要Segue公司或Interface Builder中的实际SEGUE线视图中的ID?

Hope this helps :) 希望这可以帮助 :)

EDIT: Do this: 编辑:这样做:
let vc : YourViewController storyboard.instantiateViewControllerWithIdentifier("FBLoggedInSegue") as YourViewController vc.accessToken = FBSDKAccessToken.currentAccessToken() self.presentViewController(vc, animated: true, completion:nil)

It seems the issue was present as the view controller was not getting allocated :) 似乎存在问题,因为未分配视图控制器:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM