我创建了一个方法来解除我呈现的视图控制器,显示的视图控制器确实得到了解除但是没有调用popoverPresentationControllerDidDismissPopover,如何在解除显示的视图控制器后调用popoverPresentationControllerDidDismissPopover?
func dismissPresentedViewController() {
self.presentedViewController?.dismiss(animated: true, completion: nil)
popoverPresentationController?.delegate?.popoverPresentationControllerDidDismissPopover?(popoverPresentationController!)
}
func popoverPresentationControllerDidDismissPopover(_ popoverPresentationController: UIPopoverPresentationController) {
print("Here")
}
没有调用popoverPresentationControllerDidDismissPopover,是的,我有UIPopoverPresentationControllerDelegate
let popupController = storyboard?.instantiateViewController(withIdentifier: "CommentsView") as! CommentsController
popupController.modalPresentationStyle = .popover
popupController.preferredContentSize = CGSize(width: 400, height: 400)
if let popoverController = popupController.popoverPresentationController {
popoverController.sourceView = (cell)
popoverController.sourceRect = (cell?.bounds)!
popoverController.permittedArrowDirections = .up
popoverController.delegate = self
}
present(popupController, animated: true, completion: nil)
答案 0 :(得分:1)
来自Apple's documentation ...
popoverPresentationControllerDidDismissPopover(_:)
popover表示控制器在解除后调用此方法 弹出窗口让你知道它不再在屏幕上。该 表示控制器仅在响应用户时调用此方法 动作。 如果你关闭popover,它不会调用此方法 编程。强>