Swift segue not working?

后端 未结 6 1522
一个人的身影
一个人的身影 2021-01-14 09:50

My Swift segue is not working at all and isn\'t throwing any errors. The breakpoint shows me that the app lands on this line but nothing happens:

self.perfor         


        
6条回答
  •  旧巷少年郎
    2021-01-14 10:32

    The closest I can get to overcome same problem for myself:

    Made trigger var segueLogin : Bool = false with initialised value in the Class.

    When PFFacebookUtils gets needed values for segue, change trigger to true:

    PFFacebookUtils.logInInBackground(withReadPermissions: permissions) {
                (user: PFUser?, error: Error?) -> Void in
                if let user = user {
                    if user.isNew {
                        print("User signed up and logged in through Facebook!")
                        self.segueLogin = true
    
                    } else {
                        print("User logged in through Facebook!")
                        self.segueLogin = true
                    }
                } else {
                    print("Uh oh. The user cancelled the Facebook login.")
                    self.loginCancelledLabel.alpha = 1
                }
            }
    

    Then added code to viewDidAppear class. Realised it starts everytime PFFacebookUtils complete. So it checks if returned value is true and performs segue after successful PFFacebookUtils session:

    override func viewDidAppear(_ animated: Bool) {
            if segueLogin == true {
                self.performSegue(withIdentifier: "segueSingup", sender: self)
            }
        }
    

提交回复
热议问题