应用程序无法访问您的照片或videoiOS 9

当我使用UIImagePicker访问我的照片库来select照片时,该应用程序有时会显示一个黑屏,有时还会显示一个屏幕,说我必须为我的应用程序授予访问照片的权限。 但是当我去设置 – >隐私 – >照片,那里没有应用程序,应用程序无处可见在设置。 我读到,我必须将两个值添加到我的Info.plist,但他们也没有工作。 有没有人运行相同的错误? 我正在使用xcode 7,swift 2.0和iOS 9

在这里输入图像说明

这是我提示用户进入相机的地方

@IBAction func cameraButtonPressed(sender: UIButton) { let actionSheet = UIAlertController(title: nil, message: nil, preferredStyle: UIAlertControllerStyle.ActionSheet) let cancelAction = UIAlertAction(title: "Cancel", style: .Default) { (UIAlertAction) -> Void in self.dismissViewControllerAnimated(true, completion: nil) } let cameraAction = UIAlertAction(title: "Take Photo", style: .Default) { (UIAlertAction) -> Void in if UIImagePickerController.availableCaptureModesForCameraDevice(.Rear) != nil { self.imagePicker.allowsEditing = false self.imagePicker.sourceType = UIImagePickerControllerSourceType.Camera self.imagePicker.cameraCaptureMode = .Photo self.presentViewController(self.imagePicker, animated: true, completion: nil) } else { self.noCamera() } } let photoLibraryAction = UIAlertAction(title: "Photo Library", style: .Default) { (UIAlertAction) -> Void in self.imagePicker.sourceType = UIImagePickerControllerSourceType.PhotoLibrary self.presentViewController(self.imagePicker, animated: true, completion: nil) } actionSheet.addAction(photoLibraryAction) actionSheet.addAction(cameraAction) actionSheet.addAction(cancelAction) self.presentViewController(actionSheet, animated: true, completion: nil) } 

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

你可以在那里input你的应用程序名称,它应该工作。

在info.plist中,“捆绑显示名称”字段不能为空。

如果你得到这个屏幕可能有以下原因和解决scheme:

1.如果您没有获得访问权限警报。

解决scheme :1.添加CFBundleDisplayName及其值作为应用程序标题或任何你想要的。 2.在info.plist文件中添加NSPhotoLibraryUsageDescription

2.检查您的设置 – >隐私 – >照片,隐私被禁用或启用。

解决scheme :启用照片的隐私。

3.如果您正在模拟器上工作并且已经添加CFBundleDisplayName没有获取照片访问警报。

Solation :确保您使用的Xcode必须位于Application文件夹中以获取权限访问警报。

这很简单,

进去吧

模拟器 – >硬件 – >首页

然后在手机的设置 – >在您的应用程序 – >现在允许通过像下面的图像移动开关选项

对于那些仍然在iOS 10中出现这个错误的人,这是iOS 10中实现的新的隐私设置的问题。

基本上,在Info.plist ,必须通过设置Privacy - Photo Library Usage DescriptionPrivacy - Photo Library Usage Description键(注意,这可以留为空白string)来说明为什么要访问Photo库。

更多关于这里: http : //useyourloaf.com/blog/privacy-settings-in-ios-10/

我意识到这是一个老问题,但有一个最后的提示提供…

尝试上述build议后,我仍然在运行iOS 9.3的iPod touch上遇到“相机,照片,音乐库”权限问题。 Settings app > Privacy > Photos列出了没有应用程序( Privacy > Camera ,或Privacy > Media Library )。 “设置”应用没有包含适用于我的应用的行,因此客户无法更改应用的“隐私”权限。

解决scheme是打开Settings app > General > Reset ,然后点击Reset Location & Privacy 。 显然,我的设备的隐私设置已经损坏。 重置后,所有这些问题都解决了。

对于iOS10在info.plist中

“CFBundleDisplayName”input您的应用程序名称

 <key>CFBundleDisplayName</key> <string>IMS Food-taxi</string> 

和“NSPhotoLibraryUsageDescription”添加说明

 <key>NSPhotoLibraryUsageDescription</key> <string>you will need to give the app permission to use the Photos.</string>