简体   繁体   中英

Get event of UIPopoverPresentationController when dismiss

I have viewControllerA from where I present the UIPopoverPresentationcontroller which display the static data. Please find the below code for more information.

- (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];
}

As I did not write the code for dismiss the "popup" view as it is automatically dismissed when I simply touched on the view.

So my question is that I need the event when the popup is dismissed.

Thanks in advance.

As you had already applied the delegate of UIPopoverPresentationControllerDelegate with below statement.

self.popupView.delegate = self;

List of UIPopoverPresentationControllerDelegate methods.

1) Called on the delegate when the popover controller will dismiss the popover. Return NO to prevent the // dismissal of the view.

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

2) Called on the delegate when the user has taken action to dismiss the popover. This is not called when the popover is dimissed programatically.

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

3) Notifies the delegate that the popover is about to be presented.

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

For more information please check the Apple Developer link .

For your reference popoverPresentationControllerDidDismissPopover will call when you dismiss the popup.

Hope it works for you.

看看UIPopoverPresentationControllerDelegate专门针对popoverPresentationControllerDidDismissPopover方法。

try UIPopoverControllerDelegate method

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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