应用无法访问您的照片或视频iOS 9

Man*_*noz 24 ios ios9

当我使用UIImagePicker访问我的照片库来选择照片时,该应用程序有时会向我显示黑屏,有时会显示一个屏幕,说我必须授予我的应用访问照片的权限.但是,当我进入设置 - >隐私 - >照片时,那里没有应用程序,应用程序无法在"设置"中看到.我读到我必须在我的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)

}
Run Code Online (Sandbox Code Playgroud)

小智 53

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

您可以在那里输入您的应用名称,它应该可以使用.

  • 我多年来一直在寻找这个答案.谢谢! (2认同)
  • 无法让它在这里工作....它只是第一次获得许可.添加了Bundle显示名称,将其更改为不同的字符串,也为空,删除app,DerivedData,清理项目,重启模拟器.从那时起,再也无法让它呈现弹出对话框. (2认同)

小智 6

在info.plist中,"Bundle display name"字段不能为空.


Him*_*ani 5

如果您看到此屏幕,可能有以下原因和解决方案:

1.如果您没有收到访问权限警报。

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

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

解决方案:启用照片隐私。

3.如果您正在使用模拟器并且已经添加了CFBundleDisplayName,则不会收到照片访问警报。

解决方法:确保您使用的 Xcode 必须在Application 文件夹中才能获得权限访问警报。