Swift: Popover dismiss callback

后端 未结 4 1629
太阳男子
太阳男子 2020-12-30 10:56

There are two UIViewConrollers in my Storyboard: MainViewController and SecondViewController. I\'m going to show S

4条回答
  •  无人及你
    2020-12-30 11:02

    You need to set yourself as the popOverDelegate. You have to do this in the popoverPresentationController of the destination.

    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        segue.destination.popoverPresentationController?.delegate = self
    }
    

    Then declare implement the delegates in your ViewController:

    extension FormViewController: UIPopoverPresentationControllerDelegate {
    
        func popoverPresentationControllerDidDismissPopover(_ popoverPresentationController: UIPopoverPresentationController) {
            printBreadcrumb("Dismissed popover")
        }
    
    }
    

提交回复
热议问题