在我的应用中,用户应该有权访问照片库以选择应该在 ImageView 组件中显示的照片。
我正在使用以下代码来做到这一点:
@IBAction func selectPhotoButtonTapped(sender: AnyObject) {
picker.allowsEditing = false
picker.sourceType = .PhotoLibrary
self.botonEnviar.hidden=false
presentViewController(picker, animated: true, completion: nil)
}
func imagePickerControllerDidCancel(picker: UIImagePickerController) {
dismissViewControllerAnimated(true, completion: nil)
}
func imagePickerController(
picker: UIImagePickerController,
didFinishPickingMediaWithInfo info: [String : AnyObject])
{
let chosenImage = info[UIImagePickerControllerOriginalImage] as! UIImage
myImageView.contentMode = .ScaleAspectFit
myImageView.image = resizeImage(chosenImage, newWidth: 1000)
dismissViewControllerAnimated(true, completion: nil)
}
这在模拟器上运行良好,但在真实设备上,该应用无法访问设备的照片库。
我需要在应用中包含什么才能请求用户授予访问照片库的权限? 谢谢。
最佳答案
首先,检查您的设备设置 >> 您的应用程序 >> 权限。
关于ios - 在真实设备上未授予访问照片库的权限,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35495422/