繁体   English   中英

关闭时获取UIPopoverPresentationController事件

[英]Get event of UIPopoverPresentationController when dismiss

我从显示UIPopoverPresentationcontroller的地方显示了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];
}

因为我没有编写用于关闭“弹出”视图的代码,因为当我简单地触摸视图时,它会自动关闭。

所以我的问题是,当弹出窗口关闭时,我需要该事件。

提前致谢。

正如您已经使用以下语句应用UIPopoverPresentationControllerDelegate的委托UIPopoverPresentationControllerDelegate

self.popupView.delegate = self;

UIPopoverPresentationControllerDelegate方法的列表。

1)在弹出窗口控制器将关闭弹出窗口时调用委托。 返回NO以防止//视图的关闭。

- (BOOL)popoverPresentationControllerShouldDismissPopover:(UIPopoverPresentationController *)popoverPresentationController;

2)当用户采取措施消除弹出窗口时,调用委托。 以编程方式取消弹出框时,不会调用此方法。

- (void)popoverPresentationControllerDidDismissPopover:(UIPopoverPresentationController *)popoverPresentationController;

3)通知代表该弹出窗口即将被呈现。

- (void)prepareForPopoverPresentation:(UIPopoverPresentationController *)popoverPresentationController;

有关更多信息,请检查Apple Developer链接

供您参考,当您关闭弹出窗口时, popoverPresentationControllerDidDismissPopover将调用。

希望对你有效。

看看UIPopoverPresentationControllerDelegate专门针对popoverPresentationControllerDidDismissPopover方法。

尝试UIPopoverControllerDelegate方法

    - (void) popoverControllerDidDismissPopover:(UIPopoverController *) popoverController {
   //do stuff here...
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM