1

我想從iPad應用程序訪問照片庫。據說「在iPad上,UIImagePickerController必須通過UIPopoverController呈現」。這正是我得到的日誌消息。UIImagePickerController與UIPopOverController,iPad的iOS 6

這裏是我的應用程序的快照:

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

既然我已經列出通過酥料餅的選項,它沒有任何意義從內部去另一個酥料餅。當用戶點擊「照片庫」單元時,accessPhotoLibrary方法被調用。

-(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]; 
    } 
} 

但是,如何解決這個問題,我必須使用popover訪問照片庫時,我已經使用一個?

任何幫助,非常感謝。

+0

你現在的代碼有什麼問題?看起來它會起作用。 – Undo 2013-04-11 16:48:19

+0

您需要爲圖像選擇器使用另一個「UIPopoverController」(如果是用於照片庫 - 相機應該位於全屏模式視圖控制器中)。不要重複使用該選項的小彈出窗口。順便說一句 - 爲什麼不使用「UIActionSheet」的選項? – rmaddy 2013-04-11 16:48:28

+0

@ErwaySoftware如果圖像選擇器不適用於攝像機,則UIImagePickerController必須位於iPad上的「UIPopoverController」中。 – rmaddy 2013-04-11 16:49:01

回答

0

您可以在同一個彈出窗口中顯示圖像選擇器。持有至酥料餅的引用(呈現酥料餅父視圖控制器可以通過參考),然後您可以執行以下操作:

[_parentPopover setContentViewController:imagePickerController animated:YES]; 

如果需要,您可以使用修改內容在酥料餅的呈現大小圖像選擇器視圖控制器中的屬性「contentSizeForViewInPopover」。

相關問題