iPad下单横屏下,调用图片拾取器,会导致程序异常,需要使用下面的方法来调用。
if (imagePickerController == nil) {
imagePickerController = [[UIImagePickerController alloc] init];
[imagePickerController setDelegate:self];
}
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
[self presentViewController:imagePickerController animated:YES completion:nil];
}
else
{
UIPopoverController *pop = [[UIPopoverController alloc] initWithContentViewController:imagePickerController];
currentPop = pop;
[pop presentPopoverFromRect:[sender bounds] inView:sender permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
pop.passthroughViews = nil;
}
- (void)dismissPicker: (UIImagePickerController *)picker
{
if (currentPop && currentPop.popoverVisible) {
[currentPop dismissPopoverAnimated:YES];
}
else
{
[self dismissViewControllerAnimated:YES completion:nil];
}
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
[self dismissPicker:picker];
return;
}
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
{
[self dismissPicker:picker];
}