2012-08-03 94 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

相关问题