小编Mr.*_*ity的帖子

如何在 iOS 14 中使用 PHAuthorizationStatusLimited

为了获取照片的创建日期,所以在显示 PHPickerViewController 之前使用 requestAuthorizationForAccessLevel。

    PHAccessLevel level = PHAccessLevelReadWrite;
    [PHPhotoLibrary requestAuthorizationForAccessLevel:level handler:^(PHAuthorizationStatus status) {
            if (status == PHAuthorizationStatusLimited || status == PHAuthorizationStatusAuthorized) {
                dispatch_async(dispatch_get_main_queue(), ^{
                    PHPickerConfiguration *configuration = [[PHPickerConfiguration alloc] initWithPhotoLibrary:[PHPhotoLibrary sharedPhotoLibrary]];
                    configuration.filter = [PHPickerFilter imagesFilter];
                    configuration.selectionLimit = 1;
                    PHPickerViewController *picker = [[PHPickerViewController alloc] initWithConfiguration:configuration];
                    picker.delegate = self;
                    [self showViewController:picker sender:nil];
                });
            }
    }];
Run Code Online (Sandbox Code Playgroud)

尽管状态为 .limited,但 iOS 14 仍然显示所有图像。

如何使用 PHPickerViewController 只获取有限的照片?

ios14 phpickerviewcontroller

6
推荐指数
1
解决办法
3576
查看次数

标签 统计

ios14 ×1

phpickerviewcontroller ×1