kingfoot
kingfoot

Reputation: 1289

Perform Function when Popover is Dismissed

I have a popover that is using the same view controller that calls it.

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
    if segue.identifier == "groupSelect" {
        let popVC = segue.destination
        popVC.popoverPresentationController?.delegate = self
    }
}

func adaptivePresentationStyle(for controller: UIPresentationController) -> UIModalPresentationStyle {
    return UIModalPresentationStyle.none
}

However, because I used the storyboard to make everything, I'm not really sure how or where I can take over or add code when the popover gets dismissed. In Xcode 8.2 with Swift 3, adding a popover with the storyboard editor automatically makes the popover dismiss when the user touches outside the popover. Everything is working great, the only problem is that when I return from the popover, the table under it won't have the reload function called so any changes made in the popover don't take effect for the user.

Upvotes: 1

Views: 877

Answers (1)

Sahil
Sahil

Reputation: 9226

Implement UIPopoverPresentationControllerDelegate method popoverPresentationControllerDidDismissPopover which tells the delegate that the popover was dismissed.

Upvotes: 1

Related Questions