I'm not sure if this is the most elegant solution, but it seems to work fine for me:
You can embed the UIImagePickerController view in the container view of the UIViewController.
- (void)showImagePickerForPhotoLibrary { NSLog(@"Picker"); imagePickerController = [[UIImagePickerController alloc] init]; imagePickerController.delegate = self; imagePickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; UIViewController *containerController = [[UIViewController alloc] init]; containerController.contentSizeForViewInPopover = CGSizeMake(768, 1000); [containerController.view addSubview:imagePickerController.view]; if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { Class cls = NSClassFromString(@"UIPopoverController"); if (cls != nil) { popoverController = [[UIPopoverController alloc] initWithContentViewController:containerController]; [popoverController presentPopoverFromRect:selectedRect inView:self.view permittedArrowDirections:4 animated:YES]; [imagePickerController.view setFrame:containerController.view.frame]; } } else { [app.mainViewController presentModalViewController:containerController animated:YES]; } }
Hope this helps
EDIT: for some strange reason, the frame really changes when it is in the right landscape.
To understand this, you need to set the image picker view frame after the popover view.
I changed the code above to show this.
Also, in your controller add the following:
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation { [imagePickerController.view setFrame:imagePickerController.view.superview.frame]; }
source share