Reputation: 31
I have a segue to a view controller which is in charge of authenticating the user. When the use is signed in, I want to go back to the parent view controller. Following this guide, I have created a segue from the auth view controller to it's exit. When I try to call it in code, I nothing happens.
Here is my code:
import UIKit
import Firebase
import FirebaseAuth
import GoogleSignIn
class AuthVC: UIViewController, GIDSignInUIDelegate {
@IBAction func unwindAuth(sender: UIStoryboardSegue) {
print("'unwindAuth' called")
}
override func viewDidLoad() {
super.viewDidLoad()
GIDSignIn.sharedInstance().uiDelegate = self
FIRAuth.auth()?.addStateDidChangeListener() { (auth, user) in
if FIRAuth.auth()?.currentUser != nil {
print(self.shouldPerformSegue(withIdentifier: "unwindSegue", sender: nil))
self.performSegue(withIdentifier: "unwindAuthSegue", sender: nil)
}
}
}
}
After clicking the sign in button, I get true
in the console from self.shouldPerformSegue
, but nothing else (no errors and nothing happens).
I am using Xcode Version 8.3 beta (8W109m).
I have been searching for a solution to this for a few days.
Disclaimer: I am new to Xcode, but I have been programming for almost 10 years. I have no formal training, though.
Upvotes: 0
Views: 128
Reputation: 37581
The unwind segue action must be placed on the view controller to which you want to segue back to, not on the view controller you are leaving.
If you wish to pass data back then you can use a delegate
Passing data back from view controllers Xcode
Upvotes: 3