本文介绍了允许拍照或从图书馆获取图像未显示在iOS9(Xcode 7beta,Swift2)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面的代码显示了我访问图像lib的一个例子。无论我在哪里调用代码(视图),我没有看到手机中的权限对话框弹出,因此不能允许我的应用程序访问相机或图书馆。



此外,隐私设置也不会显示我的应用程序。有什么想法吗? I'm going nuts。

  let imgPicker = UIImagePickerController()
imgPicker.sourceType = UIImagePickerControllerSourceType.PhotoLibrary
imgPicker.modalPresentationStyle = UIModalPresentationStyle.Popover
self.presentViewController(imgPicker,animated:true,completion:nil)






另一种方式我尝试了

  if UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType .Camera){
let imagePicker:UIImagePickerController = self.imagePickerController

imagePicker.allowsEditing = true
imagePicker.sourceType = UIImagePickerControllerSourceType.Camera
imagePicker.cameraCaptureMode = UIImagePickerControllerCameraCaptureMode。照片
imagePicker.cameraDevice = UIImagePickerControllerCameraDevice.Rear
imagePicker.showsCameraControls = true
imagePicker.navigationBarHidden = true
imagePicker.toolbarHidden = true
imagePicker.delegate = self

self.presentViewController(imagePicker,animated:true,completion:nil)
}


解决方案

如果捆绑显示名称未设置,请检查info.plist。




$ b

在iOS 8.1将弹出此权限窗口

但是在iOS 9中,根本没有弹出式权限。





为了解决这个问题,


The code below shows an example for my access to the image lib. No matter where I call the code (view) I do not see the permission dialog from the phone popping up and therefore cannot allow my app to access either camera or library.

Also, the privacy settings do not show my app either. Any thoughts? I'm going nuts.

       let imgPicker = UIImagePickerController()
        imgPicker.sourceType = UIImagePickerControllerSourceType.PhotoLibrary
        imgPicker.modalPresentationStyle = UIModalPresentationStyle.Popover
        self.presentViewController(imgPicker, animated: true, completion: nil)


another way I tried

            if UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.Camera) {
                let imagePicker:UIImagePickerController = self.imagePickerController

                imagePicker.allowsEditing       =   true
                imagePicker.sourceType          =   UIImagePickerControllerSourceType.Camera
                imagePicker.cameraCaptureMode   =   UIImagePickerControllerCameraCaptureMode.Photo
                imagePicker.cameraDevice        =   UIImagePickerControllerCameraDevice.Rear
                imagePicker.showsCameraControls =   true
                imagePicker.navigationBarHidden =   true
                imagePicker.toolbarHidden       =   true
                imagePicker.delegate = self

            self.presentViewController(imagePicker, animated: true, completion: nil)
            }
解决方案

Check info.plist.

if "Bundle display name" set as nothing,

At iOS 8.1 will popup permission window like this

But at iOS 9, there is no popup permission at all.

Also, no permission setting, at Setting > Privacy > Photos > Your app name.

To solve this,

这篇关于允许拍照或从图书馆获取图像未显示在iOS9(Xcode 7beta,Swift2)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-14 09:19