ios - 如何直接进入 "All Photos"相册?

标签 ios objective-c uiimagepickercontroller photo

我的代码是这样的:

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/

相关文章:

ios - 管理多个 UINavigationController 堆栈的最佳实践

ios - 如何像 iOS 中的图库一样仅在 Swift 中访问从相机拍摄的图像?

ios - 在 iOS 应用程序中使用现有的系统声音 [swift|

ios - iOS 6 MapKit 是否适用于早期版本的 iOS?

ios - 如何用#define 生成字符串?

objective-c - "The dwarfdump binary must exist and must be executable"是什么意思?

objective-c - 从自定义类填充数组的最简单方法?

swift - UIImagePickerController 与 LongPressGesture 崩溃

iphone - CGAffineTransform 反转 : singular matrix in UIImagePickerController with showsCameraControls = NO

iOS - 存储用户登录 session 的正确方法