Ios 警告:试图显示<;UIImagePickerController:0x7ca5dc00>;on<;UIViewController:0x7b9cac00>;已显示的(空)
我在使用iPad时犯了这个错误。但iPhone是有效的。请分享解决方案。我的代码如下Ios 警告:试图显示<;UIImagePickerController:0x7ca5dc00>;on<;UIViewController:0x7b9cac00>;已显示的(空),ios,objective-c,iphone,uiimagepickercontroller,Ios,Objective C,Iphone,Uiimagepickercontroller,我在使用iPad时犯了这个错误。但iPhone是有效的。请分享解决方案。我的代码如下 -(void)pickImageFromLibrary { UIImagePickerController *picker10 = [[UIImagePickerController alloc] init]; picker10.delegate = self; picker10.allowsEditing = YES; picker10.view.tag=100;
-(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];
}
UIImagePickerCopController必须在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
这里是指向类参考的链接,以获取更多信息:您应该尝试此代码
[self.presentedViewController dismissViewControllerAnimated:NO completion:nil];
请提供更多信息。“仅编码”和“尝试此”答案是错误的,因为它们不包含可搜索的内容,并且没有解释为什么有人应该“尝试此”。我们在这里努力成为知识的资源。也许这会对你有所帮助