iOS11 photo library access is possible even if settings are set to “never”

后端 未结 4 1922
悲哀的现实
悲哀的现实 2020-12-01 03:20
if UIImagePickerController.isSourceTypeAvailable(.photoLibrary) {
    let imagePicker = UIImagePickerController()
    imagePicker.sourceType = .photoLibrary
    imag         


        
4条回答
  •  南笙
    南笙 (楼主)
    2020-12-01 04:12

    UIImagePickerController and PHPhotoLibrary responsible for different areas.

    You should check both: auth status and source availability.

    PHAuthorizationStatus

    Information about your app’s authorization to access the user’s Photos library.

    isSourceTypeAvailable

    Discussion

    Because a media source may not be present or may be unavailable, devices may not always support all source types.

    For example, if you attempt to pick an image from the user’s library and the library is empty, this method returns false. Similarly, if the camera is already in use, this method returns false.

提交回复
热议问题