When I access my Photo Library with an UIImagePicker to choose a photo, the app shows me sometimes a black screen and sometimes a screen that says that I have to give permissions to my app to access the photos. But when I go to Settings -> Privacy -> Photos, there’s no app there and the app is nowhere to be seen in Settings. I read that I must add two values to my Info.plist but they didn’t worked either. Have anyone run with the same error? I’m working with xcode 7, swift 2.0 and iOS 9
This is where i prompt for user for Camera access
@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)
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…