【问题标题】:"PHPhotoLibrary.requestAuthorization" not asking permissions in iOS 9“PHPhotoLibrary.requestAuthorization”不在 iOS 9 中询问权限
【发布时间】:2015-10-06 09:26:15
【问题描述】:

它不是在 iOS 9 中询问画廊的权限,但在 iOS 8 中它可以正常工作。也许我需要info.plist 中的任何权限密钥?

 PHPhotoLibrary.requestAuthorization({ (status) -> Void in

 })

【问题讨论】:

    标签: ios swift phphotolibrary ios-permissions


    【解决方案1】:

    当您的应用程序 Info.plist 文件包含一个键:“CFBundleDisplayName”,其值为空字符串时,此问题出现在 iOS 9 中。

    您可以在那里输入您的应用名称,它应该可以工作。

    键 {Bundle display name} 值 $(PRODUCT_NAME)

    在那里发现相同的问题和解决方案 App does not have access to your photos or videos iOS 9

    【讨论】:

    • 真的是非常好的答案!对我帮助很大,非常感谢!
    • 在将 Bundle 显示名称添加到 plist 后,删除应用程序,清理,删除 DerivedData... 没什么... 没有工作。无法让它再次显示权限弹出窗口。
    • i.imgur.com/YlgHUFC.png 并尝试填写隐私 - 照片库使用说明它适用于我的情况
    【解决方案2】:

    您的 info.plist 中不需要密钥。首先确定:

    • 通过 Link Binary With Libraries 导入 Photos.framework
    • 将照片导入您的视图控制器

          let status = PHPhotoLibrary.authorizationStatus()
      
          if status == .Authorized {            
              //  Permission Authorized       
          } else if status == .Restricted {            
              //  Permission Restricted
          } else if status == .NotDetermined {        
              //  Permission Not Determined
          } else if status == .Denied {        
              //  Permission Denied
          }
      

    【讨论】:

    • 如果我们进入未确定的情况,如何让iOS权限提示出现?
    猜你喜欢
    • 1970-01-01
    • 2015-12-03
    • 2016-02-02
    • 2017-07-31
    • 2016-01-05
    • 2022-12-05
    • 1970-01-01
    • 2020-06-10
    • 1970-01-01
    相关资源
    最近更新 更多