In my ViewControllerA, I try to show ViewControllerB by calling:
let VC2 = ViewControllerB()
VC2.modalPresentationStyle = UIModalPresentationStyle.OverCurrentContext
presentViewController(VC2, animated: true, completion: nil)
So the content of ViewControllerB is shown on top of ViewControllerA.
When pressing a button in ViewControllerB, this is called:
dismissViewControllerAnimated(true, completion: nil)
However, viewWillAppear
of ViewControllerA is not called.
If the line VC2.modalPresentationStyle = UIModalPresentationStyle.OverCurrentContext
is removed, then viewWillAppear
of ViewControllerA is called.
While using UIModalPresentationStyle.OverCurrentContext
, viewWillAppear
of ViewControllerA is not called. How to detect if ViewControllerB is dismissed in ViewControllerA in this situation? I want to run some codes in ViewControllerA, but not using completion
of dismissViewControllerAnimated
in ViewControllerB.
Why don't you create your own completion block on ViewControllerB
? You can assign it when you create the instance of ViewControllerB
on ViewControllerA
, then you can just call that when you call dismissViewControllerAnimated
on ViewControllerB
.