Search code examples
iosipadios7uiimagepickercontrolleruipopovercontroller

UIImagePickerController within a popover with cancel button in iOS7


I'm showing a UIImagePickerController of type UIImagePickerControllerSourceTypePhotoLibrary inside a popover in iPad. I initialize and present the popover like this:

popoverController = [[UIPopoverController alloc]
                               initWithContentViewController:imagePicker];
[popoverController presentPopoverFromRect:popoverRect
                                   inView:self.view
                 permittedArrowDirections:UIPopoverArrowDirectionUp
                                 animated:YES]

This displays a "Cancel" button on the popover's top bar in iOS 7 right to the "Photos" title. Tapping this button does nothing and I don't find the way to handle it, how can I manage the tap event to dismiss the popover, or just remove this "Cancel" button?

Thanks


Solution

  • You will need to add this:

    - (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
    {
    
    //DO WHATEVER WHEN YOU PRESS CANCEL BUTTON (PROBABLY DISMISSING THE POPOVER
    [picker dismissViewControllerAnimated:YES completion:NULL];
    
    }