我有 viewControllerA,其中显示了显示静态数据的 UIPopoverPresentationcontroller
。
请找到以下代码以获取更多信息。
- (void)openPopupScreen:(id)sender {
PopupViewController *popupVC = [self.storyboard instantiateViewControllerWithIdentifier:@"popupViewController"];
popupVC.delegate = self;
popupVC.preferredContentSize = CGSizeMake(220.0f, 230.0f);
popupVC.modalPresentationStyle = UIModalPresentationPopover;
_popupView = popupVC.popoverPresentationController;
self.popupView.delegate = self;
self.popupView.sourceView = self.view;
self.popupView.backgroundColor = [UIColor whiteColor];
CGRect rect = CGRectMake(0.0f, 0.0f, 220.0f, 230.0f);
self.popupView.sourceRect = rect;
[self presentViewController:popupVC animated:YES completion:nil];
}
因为我没有编写关闭“弹出” View 的代码,因为当我简单地触摸该 View 时它会自动关闭。
所以我的问题是我需要弹出窗口关闭时的事件。
提前致谢。
最佳答案
因为您已经使用以下语句应用了 UIPopoverPresentationControllerDelegate
的委托(delegate)。
self.popupView.delegate = self;
UIPopoverPresentationControllerDelegate 方法列表。
1) 当弹出框 Controller 关闭弹出框时调用委托(delegate)。返回 NO 以防止 //关闭 View 。
- (BOOL)popoverPresentationControllerShouldDismissPopover:(UIPopoverPresentationController *)popoverPresentationController;
2) 当用户采取行动关闭弹出框时调用委托(delegate)。当以编程方式关闭弹出窗口时,不会调用此方法。
- (void)popoverPresentationControllerDidDismissPopover:(UIPopoverPresentationController *)popoverPresentationController;
3) 通知委托(delegate)人即将显示弹出窗口。
- (void)prepareForPopoverPresentation:(UIPopoverPresentationController *)popoverPresentationController;
更多信息请查看 Apple Developer link .
供您引用 popoverPresentationControllerDidDismissPopover
将在您关闭弹出窗口时调用。
希望它对你有用。
关于ios - 关闭时获取 UIPopoverPresentationController 事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38265378/