0

I have a view controller B which is presented as a popup by another view controller A. View controller B conforms to protocol UIPopoverPresentationControllerDelegate (defined in its header file) and implements this method.

- (void)popoverPresentationControllerDidDismissPopover:(UIPopoverPresentationController *)popoverPresentationController
{
    DDLogDebug(@"Clicked outside");
}

In view controller A, I initialize view controller B, set its modalPresentationStyle to UIModalPresentationPopover and present it using the method presentViewController:animated:completion:.

When I dismiss the popover by clicking next to it, I am not receiving any notification. Why is view controller B not receiving this notification?

The same thing happens when I make view controller A conform to UIPopoverPresentationControllerDelegate and implement the method there.

I am using Objective C and target for iOS 9.

EDIT

Thanks to the comments below, I found the mistake. I forgot to set the delegate. I now set the delegate in view controller A to itself, and let A retrieve the data that it needs from view controller B.

datePickerContentViewController.modalPresentationStyle = UIModalPresentationPopover;

UIPopoverPresentationController *popoverController = [datePickerContentViewController popoverPresentationController];
popoverController.delegate = self;

[self.parentViewController presentViewController:datePickerContentViewController animated:YES completion:nil];
physicalattraction
  • 6,485
  • 10
  • 63
  • 122

0 Answers0