1
votes

I have a Master -> Detail split view controller with a tableview on the master and a simple view on the detail viewcontroller. When I tap on an item on the detail view controller a modal vc is presented over the current context (over the detail view controller). On the iPad when the app is presented in split view, and when I tap on another item on my Master tableView, I would like to be able to determine if a modal vc is present over the detail and dismiss it before presenting the new detail content. Storyboard Image

1
Ask the detail controller whether its presentedViewController is not nil. Or never mind that; just tell it to dismiss. Does no harm if it's not presenting, so why not? (Awesome diagram by the way)matt
Thanks. That works. if let vc = self.presentedViewController as? FooViewController { vc.dismiss(animated: true) }Stewart Lynch
Good, so answer your own question and let’s close this out.matt

1 Answers

0
votes

The solution is quite simple

If let vc = self.presentedViewController as? FooViewController { 
vc.dismiss(animated: true) 
}