Reputation: 839
If I present a ViewController
like so:
let authViewController = authUI!.authViewController()
authViewController.modalPresentationStyle = .overCurrentContext
self.present(authViewController, animated: true, completion: nil)
I would like to know when the ViewController
has been dismissed. I have tried the following:
let authViewController = authUI!.authViewController()
authViewController.modalPresentationStyle = .overCurrentContext
self.present(authViewController, animated: true, completion: {
print("View Dismissed")
})
but that only lets me know if the view was presented successfully. This ViewController
was not created by me so I can't change the viewWillDissapear
method.
Upvotes: 1
Views: 2848
Reputation: 20379
Whole answer is predicated on an assumption that OP doesnt have access to authViewController
code
If you dont have access to authViewController
code, lousy solution would be to use viewWillAppear
of your view controller to find when auth view controller is dismissed.
Basically when you present/push any viewController over your existing view controller, your view controller's viewWillDisappear
will be called similarly when presented/pushed view controller is dismissed, or popped out viewWillAppear
will be called.
Because viewWillAppear
might get called for other reasons as well and you wouldnt wanna confuse it as authViewController
dismiss, use a boolean
private var shouldMonitorAuthViewControllerDismiss = false //declared a instance property
Set the boolean to true when you actually present the authViewController
let authViewController = authUI!.authViewController()
authViewController.modalPresentationStyle = .overCurrentContext
self.present(authViewController, animated: true, completion: {
shouldMonitorAuthViewControllerDismiss = true
})
Finally in your viewWillAppear
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(true)
if shouldMonitorAuthViewControllerDismiss {
//auth view controller is dismissed
}
shouldMonitorAuthViewControllerDismiss = false
}
Upvotes: 1