Permission to take photo OR get image from library not shown in iOS9 (Xcode 7beta, Swift2)

筅森魡賤 提交于 2019-12-04 12:28:49

问题


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

回答1:


You need to set a new pair of Info.plist values, same as the String for Location Services would be in iOS8:

Just set your description string for those.




回答2:


Check info.plist.

if "Bundle display name" set as nothing,

At iOS 8.1 will popup permission window like this

"" Would Like to Access Your Photos

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,

Remove "Bundle display name" in your info.plist.




回答3:


Apparently this appears to be an issue with iOS9. For some reason the permission access dialog does not pop up. I have successfully tested on iOS8, using the same code.



来源:https://stackoverflow.com/questions/31596259/permission-to-take-photo-or-get-image-from-library-not-shown-in-ios9-xcode-7bet

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!