0
votes

I'm using MZFormSheetPresentationController to show as "pop-up" a ViewController2 (embedded in a Navigation controller as suggested) over a ViewController1.

My ViewController1 has a searchbar, a UISegmentedControl and a tableview:

Image1

When user clicks on the searchbar bookmark button, pop-up is shown.

Image2

I'd like to close the pop-up when user clicks on the done button and it works great using self.dismissViewControllerAnimated(true, completion: nil) method but I'm looking for more. I'd like to present again ViewController1 so tableView will reload data. I tried with:

self.dismissViewControllerAnimated(true, completion: nil)
        print("Dismissed")

        //goToTickets
        let next = self.storyboard?.instantiateViewControllerWithIdentifier("myTabBar") as! UITabBarController
        self.presentViewController(next, animated: true, completion: nil)

but I get this error:

Warning: Attempt to present on whose view is not in the window hierarchy!

Pop-up disappears but I can't present ViewController.

How can I do?

Thanks in advance.

Edit

This is my ViewController2 with identifier "navigationFilter"

Image4

and my tabBar:

Image5

1

1 Answers

1
votes

When you are in the middle of dismissing you are trying to present next ViewController, you have to wait for completion handler and then present next view controller like this:

self.dismissViewControllerAnimated(true, completion: {
    let next = self.storyboard?.instantiateViewControllerWithIdentifier("myTabBar") as! UITabBarController
    self.presentViewController(next, animated: true, completion: nil)
})