我知道我可以使用 popoverPresentationControllerDidDismissPopover
但只有当用户点击弹出窗口 View 外部以关闭它时才会调用它。
当我手动关闭弹出窗口时(self.dismissViewControllerAnimated(true, completion: nil)
在弹出窗口的 ViewController 中)没有任何反应。
最佳答案
弹出窗口关闭!
有两种检测弹出窗口关闭的方法:
- 在
mainViewController
中检测,它实际生成的地方,我的意思是ParentViewController
。
使用parentViewController
作为主生成个人
class ViewController: UIViewController, UITableViewDataSource,
UITableViewDelegate, UIPopoverPresentationControllerDelegate {
现在实现这些功能:
public func adaptivePresentationStyle(for controller: UIPresentationController) -> UIModalPresentationStyle {
return .none
}
public func popoverPresentationControllerDidDismissPopover(_ popoverPresentationController: UIPopoverPresentationController) {
print("Popover dismisssed")
}
- 在用于处理 Storyboard 中制作的
popOverView
的 Controller 中进行检测。
func dismiss() {
self.dismiss(animated: true, completion: nil)
print("DISMISSS")
}
@IBAction func cancelClicked(_ sender: Any) {
dismiss()
}
注意:对于 Storyboard,您可以询问更多详细信息。
关于xcode - 检测弹出窗口关闭,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36246574/