1

我在 iPad 模拟器上工作,我想在 iPad 照片库中查看图像,但它有问题:

'NSInvalidArgumentException',原因:'在 iPad 上,UIImagePickerController 必须通过 UIPopoverController 呈现'

这是我的代码。帮我!

- (IBAction)ShowGallery:(id)sender {
        if([UIImagePickerController isSourceTypeAvailable:
            UIImagePickerControllerSourceTypePhotoLibrary]) {
            picker = [[UIImagePickerController alloc]init];
            picker.delegate = self;
            picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
            [self presentModalViewController:picker animated:YES];
        }
4

1 回答 1

0

您必须在 iPad 中使用 PopoverController 而不是 PresentModalViewController。您可以使用以下代码

 UIPopoverController *popOver =[[UIPopoverController alloc] initWithContentViewController:picker];
    [popOver setPopoverContentSize:CGSizeMake(315.0 , 245.0) animated:YES];

    [popOver presentPopoverFromRect:takePictureButton.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];    
[picker release];
于 2013-05-15T10:54:04.003 回答