【问题标题】:iOS 14 still display entire photo library despite of .limited status尽管处于 .limited 状态,iOS 14 仍会显示整个照片库
【发布时间】:2020-12-01 19:32:23
【问题描述】:
let accessLevel : PHAccessLevel = .readWrite
  let phStatus = PHPhotoLibrary.authorizationStatus(for: accessLevel)
  if (phStatus == .notDetermined) {
    PHPhotoLibrary.requestAuthorization(for: accessLevel) {
      newStatus in
        if (newStatus == .limited) {
        var conf = PHPickerConfiguration()
        conf.selectionLimit = 1
        conf.filter = .any(of: [.images, .livePhotos])
        let picker = PHPickerViewController(configuration: conf)
        picker.delegate = self
        self.present(picker, animated: true)
      }
    }
  }

我使用上面的代码来测试 iOS 14 的新功能 Limited Photos Library。 在我使用新的 Api authorizationStatusrequestAuthorization 的代码中, 并成功获得 .limited 状态。但是尽管 .limited 状态,iOS 14 仍然显示所有 图书馆的照片。谁能帮我解决这个问题?

【问题讨论】:

    标签: ios swift3


    【解决方案1】:

    .limited 状态不会影响 PHPickerViewController。事实上,即使是.denied 状态也不会影响 PHPickerViewController!

    选择器是进程外的,不涉及用户授权。您配置和呈现选择器的方式是要求图像,而不是直接访问照片库;并且您只会收到用户个人选择的图像。

    因此不需要事先的用户授权,并且完全不相关。 var conf = PHPickerConfiguration()之前的所有代码都可以删除。

    【讨论】:

    • 这是正确的答案。 PHPicker doesn't require the user to grant photo library access.
    猜你喜欢
    • 2023-04-08
    • 1970-01-01
    • 2020-12-31
    • 2021-06-05
    • 1970-01-01
    • 2019-03-21
    • 2020-02-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多