Reputation: 1071
I have a secondary ViewController that appears programmatically via a Storyboard segue:
func actioncall ()
{
performSegue(withIdentifier: "showIgnoreVC", sender: self)
}
)
This function is part of the main ViewController, and is called via an NSNotification from the AppDelegate, which in turn is triggered by a Menu Item click.
However, even though the segue is connected to the main ViewController, the following code does not dismiss the secondary view:
@IBAction func dismiss(_ sender: Any)
{
print("Hello? Gonna close?")
self.presenting?.dismissViewController(self)
}
There are no errors, the function is called upon the correct Dismiss button click, but the secondary view does not dismiss. I have tried every variation of dismissViewController to no avail.
When I use a button on the Main view to activate the same segue, everything works as it is supposed to. I simply do not wish to clutter up the main View with a bunch of buttons.
Any ideas are appreciated, thank you very much.
Upvotes: 2
Views: 986
Reputation: 383
dismissViewController works only for view controllers, that were presented modally (using Present Modally Segue
)
As said in the answer to this SO question, you should dismiss view controllers, presented by Show Segue
, like this:
navigationController?.popViewController(animated: true)
dismiss(animated: true, completion: nil)
Upvotes: 0