我有同样的问题,但我以这种方式解决了。
如果您
从相机拍摄图片 1)(在两个都打开为 UINavigationcontroller)2)从图库(对于 ipad 作为 UIpopovercontroller 打开和对于 iphone 作为 nvigationcontroller 打开)
第一组委托
@interface camera : UIViewController <UIImagePickerControllerDelegate, UINavigationControllerDelegate,UIPopoverControllerDelegate>
从相机获取图像后
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
{
UIImagePickerController *imagePicker =
[[UIImagePickerController alloc] init];
imagePicker.delegate = self;
imagePicker.sourceType =
UIImagePickerControllerSourceTypeCamera;
imagePicker.mediaTypes = [NSArray arrayWithObjects:
(NSString *) kUTTypeImage,
nil];
imagePicker.allowsEditing = YES;
imagePicker.wantsFullScreenLayout = YES;
[self presentViewController:imagePicker animated:YES completion:nil];
newMedia = YES;
iscamera = 0;
}
else
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error to access Camera"
message:@""
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
}
&从图库中获取图像
if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary])
{
UIImagePickerController *_picker=nil;
if (popoverController) {
[popoverController dismissPopoverAnimated:NO];
}
_picker = [[UIImagePickerController alloc] init];
_picker.delegate = self;
_picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
_picker.wantsFullScreenLayout = YES;
//[popoverController presentPopoverFromBarButtonItem:sender
// permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
[self presentViewController:_picker animated:YES completion:nil];
} else
{
popoverController = [[UIPopoverController alloc] initWithContentViewController:_picker];
[popoverController setDelegate:self];
[popoverController presentPopoverFromRect:btn.frame
inView:self.view
permittedArrowDirections:UIPopoverArrowDirectionLeft
animated:YES];
}
}
else
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error access photo library"
message:@"your device non support photo library"
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
}
您在委托方法中获得的两个结果
-(void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingMediaWithInfo:(NSDictionary *)info
{
}