美文网首页
iOS 10 拍照 获取相册权限

iOS 10 拍照 获取相册权限

作者: yunFeng | 来源:发表于2016-08-23 13:46 被阅读1429次

    2016WWDC 大会上 苹果是越来越注重用户隐私了  所以我们以后获取权限的时候要做的工作就要增加了,随着新系统 beat 的发布 个人也安装了 MacOS 和 iOS10 但是今天做到一个需求 奔溃了 于是就一万只。。。(你懂的)

    废话说完了 说正题  iOS 10 以后当我们调用系统相册或者相机的时候  虽然会弹出 alert 询问用户是否允许  但是我们还需要在项目的 info 中配置 一些参数 就和当初 HTTPS 时一样  如果还是需要使用 http 的话 我们就需要额外添加 description

    测试环境:

    Xcode 8.0 beta6 

    iOS 10(14A5322e)

    当我们在 iOS 10真机上调用相册或相机是 会奔溃  并且或报错 如下

    相机:

     [access] This app has crashed because it attempted to access privacy-sensitive data without a usage description.The app's Info.plist must contain an NSCameraUsageDescription key with a string value explaining to the user how the app uses this data.


    相册:

     [access] This app has crashed because it attempted to access privacy-sensitive data without a usage description.The app's Info.plist must contain an NSPhotoLibraryUsageDescription key with a string value explaining to the user how the app uses this data.


    看到报错信息 我们就知道是访问权限的问题 同时也告诉我们改如果去修改完善


    效果图

    添加以后 我们再次运行 操作 就可以了 

    如有不对的地方,欢迎吐槽指导。。。。

    相关文章

      网友评论

          本文标题:iOS 10 拍照 获取相册权限

          本文链接:https://www.haomeiwen.com/subject/lvxnsttx.html