Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detect popover dismiss

I know I can use popoverPresentationControllerDidDismissPopover but that is only called when the user taps outside the popover view to dismiss it. When I dismiss the popover manually (self.dismissViewControllerAnimated(true, completion: nil) in the popover's ViewController) nothing happens.

like image 389
Pixel Avatar asked Mar 27 '16 10:03

Pixel


1 Answers

Popover Dismiss!

There are two ways of detecting popover dismiss:

  1. Detecting in mainViewController, where it was actually generated, I mean ParentViewController.

Using the parentViewController as the main generating personal

class ViewController: UIViewController, UITableViewDataSource,
UITableViewDelegate, UIPopoverPresentationControllerDelegate {

And now implementing these functions:

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

public func popoverPresentationControllerDidDismissPopover(_ popoverPresentationController: UIPopoverPresentationController) {
    print("Popover dismisssed")
}
  1. Detecting in the controller used to handle popOverView made in storyboard.
func dismiss() {
    self.dismiss(animated: true, completion: nil)
    print("DISMISSS")
}
    
@IBAction func cancelClicked(_ sender: Any) {
    dismiss()
}

NOTE: For storyboards you can ask further details.

like image 188
Asim Khan Avatar answered Nov 10 '22 00:11

Asim Khan