In my iOS app, a user can select an image from a list, upon which they are presented with a modal that contains the image and options to delete the image. If the user chooses t
This may help anyone who have same problem on UIPopovePresentationController. From my experience, Allan's answer can resolve the same issue too.
I've just have problem about Viewcontroller's delegate that present as UIPopoverPresentingController didn't send call to its root view. And Allan's answer can solved this fit.
My sample code:
-(IBAction)choosePic:(id)sender
{
UIButton *picButton = (UIButton *)sender;
// Set PopoverPresentation view controller
PicViewController *picVC = [self.storyboard instantiateViewControllerWithIdentifier:@"PicViewController"];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:picVC];
picVC.preferredContentSize = CGSizeMake(500., 500.);
// Set this function as described in Allan's answer
picVC.dismissPopover = ^(UIViewController *controller, UIImage *image)
{
_myImage = image;
.....
.....
.....
};
navController.modalPresentationStyle = UIModalPresentationPopover;
_picPopover = navController.popoverPresentationController;
_picPopover.delegate = self;
_picPopover.sourceView = self.view;
_picPopover.sourceRect = [picButton frame];
navController.modalPresentationStyle = UIModalPresentationPopover;
navController.navigationBarHidden = YES;
[self presentViewController:navController animated:YES completion:nil];
}