2015-05-29 107 views
3

我在使用iPad时出现此错误。但iPhone正在工作。请分享解决方案。我的代码如下。警告:尝试在<UIViewController:0x7b9cac00>上呈现<UIImagePickerController:0x7ca5dc00>,它已经呈现(空)

-(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

可能,这将帮助你http://stackoverflow.com/questions/24942282/uiimagepickercontroller-not-presenting-in-ios-8 – Aznix

回答

0

UIImagePickerCopntroller必须在iPad的弹出窗口中显示。看看下面的代码为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]; 
} 

不要忘记加上强大的属性为酥料饼:

@property (nonatomic, strong) UIPopoverController *popOver; 

这里有贬的委托方法:

-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info 

-(void)imagePickerControllerDidCancel:(UIImagePickerController *)picker 

这里是链接到更多信息的类参考:Class Refference

2

y你应该试试这个代码!

[self.presentedViewController dismissViewControllerAnimated:NO completion:nil]; 
+3

请[编辑]更多的信息。只有代码和“试试这个”的答案是[不鼓励](http://meta.stackexchange.com/questions/196187),因为它们不包含可搜索的内容,也没有解释为什么有人应该“试试这个”。我们在这里努力成为知识的资源。 – Mogsdad

相关问题