Search code examples
iosipadios6uiimagepickercontroller

iOS6 on iPad UIImagePickerController issue


My app uses UIImagePickerContoller and it works fine with iOS 7 (iPad and iPhone) but only works on the iPhone with iOS 6. On the iPad with iOS 6 it crashes in the simulator when I click on the button that uses this class to select a picture from the photo library, but does not indicate why in the debugger log. My app is restricted to portrait view. The code is below:

-(IBAction)selectPicturePressed:(id)sender
{
    //Open a UIImagePickerController to select the picture
    UIImagePickerController *imgPicker = [[UIImagePickerController alloc] init];
    imgPicker.delegate = self;
    imgPicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;

    [self.navigationController presentViewController:imgPicker animated:YES  completion:nil];
}

Solution

  • UIImagePickerController must be presented in a UIPopoverController when the source type is the photo library.