【问题标题】:how to get Permissions for photos access in iOS 9 with photos framework如何使用照片框架在 iOS 9 中获取照片访问权限
【发布时间】:2016-09-01 02:02:52
【问题描述】:

我想通过iOS9中的照片框架和Swift 2获取照片。照片框架不允许访问图像并且不要求访问权限。

【问题讨论】:

    标签: ios permissions swift2


    【解决方案1】:

    只需在构建阶段的“Link Binary With Libraries”中添加照片框架,然后在需要的类中导入框架。

    要访问照片权限,您需要在 plist 文件中提供“捆绑显示名称”

    并使用以下代码

    PHPhotoLibrary.requestAuthorization { (status) -> Void in
    
                switch status{
                case .Authorized:
                    dispatch_async(dispatch_get_main_queue(), {
                        print("Authorized")
                     })
                    break
                case .Denied:
                    dispatch_async(dispatch_get_main_queue(), {
                        print("Denied")
                    })
                    break
                default:
                    dispatch_async(dispatch_get_main_queue(), {
                        print("Default")
                    })
                    break
                }
            }
    

    【讨论】:

      猜你喜欢
      • 2014-08-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-08-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多