Storyboard popover dismissed, delegate methods not called
<p>I have a view controller that's presented in a popover using a storyboard segue.</p>

<p><a href="https://i.stack.imgur.com/kTfeD.png" rel="noreferrer"><img src="https://i.stack.imgur.com/kTfeD.png" alt="enter image description here"></a></p>

<p>In the presenting view controller, I had the following code:</p>

<pre><code>override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
    if let svc = segue.destinationViewController as? SettingsViewController {
        svc.popoverPresentationController?.delegate = self
    }
}
</code></pre>

<p>However, it turns out that the presented view controller, even though it appears as a popover, has a <code>modalPresentationStyle</code> of <code>'.Modal</code>, and hence a <code>nil</code> <code>popoverPresentationController</code>. Weird! </p>

<p>So, I updated the code as follows:</p>

<pre><code>override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
    if let svc = segue.destinationViewController as? SettingsViewController {
        svc.modalPresentationStyle = .Popover
        svc.popoverPresentationController?.delegate = self
    }
}
</code></pre>

<p>The <code>svc.popoverPresentationController</code> delegate is now set OK, but if the popover is dismissed by the user tapping outside, none of the <code>UIPopoverPresentationControllerDelegate</code> delegate methods (e.g. <code>popoverPresentationControllerShouldDismissPopover</code> are called. What am I missing?</p>