我正在尝试让IPAD从相册中选择一张照片
pickerController = [ [ UIImagePickerController alloc ] init ] ;
pickerController.delegate = self ;
pickerController.editing = NO ;
pickerController.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
[ self presentViewController : pickerController animated : YES completion : nil ] ;当我在iPad上使用它时,这个应用程序总是崩溃,但在iPhone上运行得很好。
发布于 2012-08-03 08:58:34
这一次我也被抓到了。在iPad上,如果将源类型指定为UIImagePickerControllerSourceTypePhotoLibrary或UIImagePickerControllerSourceTypeSavedPhotoAlbum,则需要使用popover控制器显示图像拾取器控制器。如果你试图以情态的方式呈现它,就像你正在做的那样,你会得到一个异常。
不是100%必需的,但是使用测试来查看哪些源代码类型是可用的也是一个好主意。
[UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]源类型包括:
UIImagePickerControllerSourceTypePhotoLibraryUIImagePickerControllerSourceTypeSavedPhotosAlbum 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];
}https://stackoverflow.com/questions/11787828
复制相似问题