问题描述:

In my app, the user should have access to Photo Library to select a photo that should be shown in an ImageView component.

I am using following code to do it:

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

}

That works fine on the simulator, but on a real device, the app doesn't have access to the device's Photo Library.

What do I need to include in the app to ask the user for permission to access the Photo Library?

Thank you.

网友答案:

Fisrt of all, Check in your device settings >> Your App >> Permission.

相关阅读:
Top