我在使用iPad时遇到此错误。但iPhone是有效的。请分享解决方案。我的代码如下。
-(void)pickImageFromLibrary
{
UIImagePickerController *picker10 = [[UIImagePickerController alloc] init];
picker10.delegate = self;
picker10.allowsEditing = YES;
picker10.view.tag=100;
picker10.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentViewController:picker10 animated:YES completion:NULL];
}
答案 0 :(得分:2)
你应该尝试这个代码!
[self.presentedViewController dismissViewControllerAnimated:NO completion:nil];
答案 1 :(得分:0)
UIImagePickerCopntroller必须在iPad中以popover呈现。看一下iPad的以下代码:
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
UIPopoverController *popover = [[UIPopoverController alloc] initWithContentViewController:picker];
[popover presentPopoverFromRect:self.selectedImageView.bounds inView:self.selectedImageView permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
self.popOver = popover;
} else {
[self presentModalViewController:picker animated:YES];
}
不要忘记为popover添加强大的属性:
@property (nonatomic, strong) UIPopoverController *popOver;
这是解雇它的委托方法:
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
-(void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
这是指向更多信息的类引用的链接:Class Refference