1

dismissViewController doesn't call it's completing handler all the time. I am presenting first view, when I dismiss it, it calls completion handler, where I am presenting 2 view. While dismissing 2nd view, completion handler is not being called. Here is my code:

if self.presentedViewController != nil {
// Checking it to make sure that I have presentedViewController and it is not dismissed already.
    self.dismissViewControllerAnimated(false, completion: {            
         //Present 2nd controller.
    })
}
Kapil Choubisa
  • 4,970
  • 8
  • 59
  • 99
  • where have you put this code? – Ocunidee Jan 30 '17 at 14:48
  • if you dismiss self, won't the vc deallocate before it can run the completion block? – Wez Jan 30 '17 at 14:55
  • When `animation` parameter is set to `false`, completion block will NOT be called because the code is synchronous and can be placed outside the block.. – Brandon Jan 30 '17 at 15:11
  • Possible duplicate of [modal View controllers - how to display and dismiss](http://stackoverflow.com/questions/14907518/modal-view-controllers-how-to-display-and-dismiss) – Honey Jan 30 '17 at 16:28
  • Also see [Dismissing a Presented View Controller](https://stackoverflow.com/questions/14636891/dismissing-a-presented-view-controller) – Honey Jan 30 '17 at 16:28

1 Answers1

0

You can not present a second UIViewController from the dismissed UIViewController because you are dismissing the "presenter".

You need to put your "Present 2nd controller" in your PRESENTING UIViewController that is before (presenting) the UIViewController you are dismissing.

Basically, you dismiss the UIViewController and when you come back to your presenting VC, you present the 2nd controller instead.