Ask permission to access Camera Roll

后端 未结 7 1271
生来不讨喜
生来不讨喜 2020-11-28 22:39

I have a settings view where the user can choose switch on or off the feature \'Export to Camera Roll\'

When the user switches it on for the first time (and

7条回答
  •  我在风中等你
    2020-11-28 23:03

    iOS 9.2.1, Xcode 7.2.1, ARC enabled

    'ALAuthorizationStatus' is deprecated: first deprecated in iOS 9.0 - Use PHAuthorizationStatus in the Photos framework instead

    Please see this post for an updated solution:

    Determine if the access to photo library is set or not - PHPhotoLibrary (iOS 8)

    Key notes:

    • Most likely you are designing for iOS7.0+ as of todays date, because of this fact you will need to handle both ALAuthorizationStatus and PHAuthorizationStatus.

    The easiest is to do...

    if ([PHPhotoLibrary class])
    {
       //Use the Photos framework
    }
    else
    {
       //Use the Asset Library framework
    }
    
    • You will need to decide which media collection you want to use as your source, this is dictated by the device that your app. will run on and which version of OS it is using.

    • You might want to direct the user to settings if the authorization is denied by user.

提交回复
热议问题