" PHPhotoLibrary.requestAuthorization"没有在iOS 9中询问权限

时间:2015-10-06 09:26:16

标签: ios swift phphotolibrary ios-permissions

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

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

 })

2 个答案:

答案 0 :(得分:5)

当您的应用程序Info.plist文件包含密钥时,此问题会出现在iOS 9中:" CFBundleDisplayName"空字符串值。

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

key {Bundle display name} value $(PRODUCT_NAME)

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

答案 1 :(得分:0)

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

  • 通过Link Binary With Libraries导入Photos.framework
  • 将照片导入View Controller

        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
        }