我想让IPAD从相册中选择一张照片
pickerController = [ [ UIImagePickerController alloc ] init ] ;
pickerController.delegate = self ;
pickerController.editing = NO ;
pickerController.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
[ self presentViewController : pickerController animated : YES completion : nil ] ;
Run Code Online (Sandbox Code Playgroud)
当我在iPad上使用它时,该应用程序不断崩溃,但在iPhone上运行良好.
这个也让我受够了.在iPad上,如果指定源类型,UIImagePickerControllerSourceTypePhotoLibrary或者UIImagePickerControllerSourceTypeSavedPhotoAlbum需要使用弹出控制器显示图像选择器控制器.如果你尝试以模态方式呈现它,就像你正在做的那样,你会得到一个例外.
不是100%要求,但使用测试来查看可用的源类型也是一个好主意.
[UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]
Run Code Online (Sandbox Code Playgroud)
源类型是:
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];
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1449 次 |
| 最近记录: |