我的代码是这样的:
oldPicker = [[UIImagePickerController alloc] init];
if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary])
{
oldPicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
oldPicker.mediaTypes = [UIImagePickerController availableMediaTypesForSourceType:oldPicker.sourceType];
}
oldPicker.delegate = self;
oldPicker.allowsEditing = NO;
[self presentViewController:oldPicker animated:YES completion:nil];
效果是当我点击按钮时,它显示了选择 View 的相册,但我只想跳过选择 View 的相册并直接显示“所有照片”相册。
我尝试将 sourceType
设置为 UIImagePickerControllerSourceTypeSavedPhotosAlbum
,但它显示“Moments”相册而不是“All Photos”相册
最佳答案
使用 UIImagePickerController
无法做到这一点。
UIImagePickerControllerSourceType
只有 3 个值可用。
enum { UIImagePickerControllerSourceTypePhotoLibrary, UIImagePickerControllerSourceTypeCamera, UIImagePickerControllerSourceTypeSavedPhotosAlbum }; typedef NSUInteger UIImagePickerControllerSourceType;
Constants
UIImagePickerControllerSourceTypePhotoLibrary
Specifies the device’s photo library as the source for the image picker controller.
UIImagePickerControllerSourceTypeCamera
Specifies the device’s built-in camera as the source for the image picker controller. Indicate the specific camera you want (front or rear, as available) by using the cameraDevice property.
UIImagePickerControllerSourceTypeSavedPhotosAlbum
Specifies the device’s Camera Roll album as the source for the image picker controller. If the device does not have a camera, specifies the Saved Photos album as the source.
因此,为了实现您提到的场景,您需要编写自己的图像选择器。有一个自定义控件可用,您也可以查看 CTAssetsPickerController
关于ios - 如何直接进入 "All Photos"相册?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28270220/