【问题标题】:App does not have access to your photos or videos iOS 9应用程序无法访问您的照片或视频 iOS 9
【发布时间】:2015-12-22 10:47:49
【问题描述】:

当我使用 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)

}

【问题讨论】:

  • 您的应用是否真的请求访问权限?
  • @ChrisSlowik 它实际上并没有显示请求权限的对话框
  • 你在你的代码中告诉它吗?我问你做了什么。你没有给出任何迹象表明你实际上正在做应该做的事情来请求访问,所以很难说什么是错的。如果您没有告诉您的应用请求许可,那就是您的问题。否则你可能会遇到另一个问题。
  • 你说:“这是我提示用户访问相机的地方”。我说哪里?我在那里没有看到提示访问相机的代码。
  • 我问了一个类似的问题并提供了更多细节,但仍然无法弄清楚:stackoverflow.com/questions/32834212/…

标签: ios ios9


【解决方案1】:

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

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

【讨论】:

  • 我多年来一直在寻找这个答案。谢谢!
  • 无法让它在这里工作......它只在第一次请求许可。添加捆绑显示名称,将其更改为不同的字符串,也为空,删除应用程序,DerivedData,清理项目,重新启动模拟器。从那时起,无法让它再次呈现弹出对话框。
  • 非常感谢你是我的英雄!
  • @bauerMusic。你解决问题了吗?
  • @AvijitNagare 经过进一步阅读,似乎是设计使然。在此处打开(更具体地说)stackoverflow.com/questions/35083401/…
【解决方案2】:

在 info.plist 中,“Bundle display name”字段不能为空。

Example

【讨论】:

    【解决方案3】:

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

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

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

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

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

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

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

    【讨论】:

    • 确保您使用的 Xcode 必须在 Application 文件夹中以获得权限访问警报保存我的一天 tks
    • 什么??? Application 文件夹中的 XCode 与实际 ios 设备上发生的事情有关?!
    【解决方案4】:

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

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

    更多信息在这里: http://useyourloaf.com/blog/privacy-settings-in-ios-10/

    【讨论】:

      【解决方案5】:

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

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

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

      【讨论】:

        【解决方案6】:

        对于 iOS10 在 info.plist 中

        “CFBundleDisplayName”输入您的应用名称

        <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>
        

        【讨论】:

        • 它只是第一次问我,但如果被拒绝并且你再次请求它永远不会问...
        【解决方案7】:

        很简单,

        进去

        模拟器->硬件->首页

        然后在手机设置中 -> 在您的应用中 -> 现在通过移动开关选项允许 like below image

        【讨论】:

          猜你喜欢
          • 2013-10-17
          • 1970-01-01
          • 1970-01-01
          • 2015-03-14
          • 1970-01-01
          • 2017-04-24
          • 1970-01-01
          相关资源
          最近更新 更多