ios - 应用程序无法访问您的照片或视频 iOS 9

标签 ios ios9

当我使用 UIImagePicker 访问我的照片库来选择照片时,该应用程序有时会显示黑屏,有时会显示一个屏幕,提示我必须向我的应用程序授予访问照片的权限。但是当我进入“设置”->“隐私”->“照片”时,那里没有应用程序,并且在“设置”中也看不到该应用程序。我读到我必须向 Info.plist 添加两个值,但它们也不起作用。有人运行时遇到同样的错误吗?我正在使用 xcode 7、swift 2.0 和 iOS 9

enter image description here

这是我提示用户访问相机的地方

@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”且值为空字符串时,iOS 9 中会出现此问题。

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

关于ios - 应用程序无法访问您的照片或视频 iOS 9,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32923458/

相关文章:

ios - UIFlowLayoutSection.updateEstimatedSizeForSection 中的 EXC_ARITHMETIC

ios - Error Domain = NSURLErrorDomain代码= -1005“网络连接丢失。” -在iOS 9中通过https发生

ios9 - NSAppTransportSecurity:不使用正确的设置

ios - iPv6 支持可达性等级

ios - PHAsset:使用元数据保存新图像

ios - Swift MFMailComposeViewController addAttachmentData JPG 设置最大分辨率

iphone - 如何为 iPhone 创建仅资源包

ios - 在 Xcode 中均匀分布按钮

ios - 为什么 Xcode 在创建类时生成 "unnecessary"代码?

iphone - 拦截复制、粘贴、定义 UIWebView 中的 popover