1

I am trying access the Photo Library from an iPad application. It is said that "On iPad, UIImagePickerController must be presented via UIPopoverController". That's exactly the log message that I get too.

Here is a snapshot of my app:

https://www.evernote.com/shard/s241/sh/b0283978-b50b-425f-8e8f-b9a5a171c463/de48b8b2dfe7716fe304e85a18ecacfc

Since I am already listing the options via a popover, it doesn't make sense to go another popover from within. The accessPhotoLibrary method gets called when the user taps on the "Photo Library" cell.

-(void)accessPhotoLibrary{
    NSLog(@"Photo library access requested!");
    if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]){
        NSLog(@"Photo Library");
        [imagePickerController setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
        [imagePickerController setDelegate:self];
        [imagePickerController setModalPresentationStyle:UIModalPresentationFullScreen];
        [self presentViewController:imagePickerController animated:YES completion:nil];
    }
    else{
        UIAlertView *alert = [[UIAlertView alloc]
                              initWithTitle: @"Photo Library"
                              message: @"Sorry, couldn't open your photos library"
                              delegate: nil
                              cancelButtonTitle:@"OK"
                              otherButtonTitles:nil];
        [alert show];
    }
}

But how do I get around this problem of having to access the photo library using a popover when I am using one already??

Any help is much appreciated.

4

1 回答 1

0

您可以在同一个弹出框中显示图像选择器。持有对弹出框的引用(呈现弹出框的父视图控制器可以传递引用),然后您可以执行以下操作:

[_parentPopover setContentViewController:imagePickerController animated:YES];

如果需要,您可以使用图像选择器视图控制器中的属性“contentSizeForViewInPopover”更改弹出窗口中显示的内容的大小。

于 2013-04-18T17:06:39.910 回答