2012-08-03 64 views
1

我試圖獲取iPad可供選擇相冊Ipad的照片選擇器

  pickerController = [ [ UIImagePickerController alloc ] init ] ; 
      pickerController.delegate = self ; 
      pickerController.editing = NO ; 
      pickerController.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum; 

      [ self presentViewController : pickerController animated : YES completion : nil ] ; 

當我使用它在iPad上的應用程式經常當照片,但在iPhone上正常工作。

回答

6

這一個也得到了我之前。如果您在iPad上指定源類型UIImagePickerControllerSourceTypePhotoLibraryUIImagePickerControllerSourceTypeSavedPhotoAlbum,則需要使用彈出式控制器來呈現圖像選取器控制器。如果您嘗試以模態方式呈現它,就像您正在做的那樣,您會得到一個異常。

不是100%必需的,但使用測試來查看可用的源類型也是一個好主意。

[UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary] 

源類型:

  • UIImagePickerControllerSourceTypePhotoLibrary
  • UIImagePickerControllerSourceTypeSavedPhotosAlbum
  • UIImagePickerControllerSourceTypeCamera

這是我如何解決這個問題,以測試它是否是一個iPad與否。

if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad){ 

    UIPopoverController* popOverController = [[UIPopoverController alloc] initWithContentViewController:imagePickerController]; 
    [popOverController presentPopoverFromRect:selectVideoToViewButton.bounds inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES]; 

}else { 
    [self presentModalViewController:self.imagePickerController animated:YES]; 
} 
+0

是的,在文檔概要的音符步驟4 - > http://developer.apple.com/library/ios/#documentation/uikit/reference/UIImagePickerController_Class/UIImagePickerController/UIImagePickerController.html – borrrden 2012-08-03 01:03:15