Imagine you’re presenting a view controller in your storyboard via a Popover Segue: Simply drag from a button in your Main View Controller to your Other View Controller, and under segue select “Popover”. Works like a charm: the popover is presented, and if someone clicks outside the popover it is dismissed. Marvellous!
Surely we should be able to add a button inside our popover, and create an IBAction in which we call something like “dismissPopover:animated”. But of course there isn’t – at least not if you’re presenting a UIViewController.
Things would be easier if we had created our popover in code, where we could create a UIPopoverController (which has a method that dismisses it) – but if you’ve ever tried, that’s just not possible when using Storyboards: because with Storyboards, all we can create is a UIViewController, and it just doesn’t have a popover dismissal method.
So how do we do this instead?This content is for members only.
This notification is picked up by our Main View Controller which acts accordingly and can dismiss our popover because it holds a reference to it.
Another mystery solved 😉