I have the following function that displays an action sheet with two different options. Currently, the only implemented option is the titled "Photos". The action sheet is presented correctly and the proper action gets called. My problem is that on the simulator and on an actual device, I can not get to display the prompt requesting access to the photo library.
PHPhotoLibrary.authorizationStatus()
returns .Denied
and presents the modal informing the current app does not have access to the photos:
@IBAction func attachPhotoButtonTapped(sender: AnyObject) {
let actionSheetController = UIAlertController(title: "Images", message: "Select image source...", preferredStyle: .ActionSheet)
let cancelAction = UIAlertAction(title: "Cancel", style: .Cancel) {
(action) in
// ...
}
actionSheetController.addAction(cancelAction)
let takePictureAction = UIAlertAction(title: "Camera", style: .Default) {
(action) in
// ...
}
actionSheetController.addAction(takePictureAction)
let choosePictureAction = UIAlertAction(title: "Photos", style: .Default) {
(action) in
PHPhotoLibrary.requestAuthorization({(status:PHAuthorizationStatus) in
switch status{
case .Authorized:
dispatch_async(dispatch_get_main_queue(), {
print("Authorized")
})
break
case .Denied:
dispatch_async(dispatch_get_main_queue(), {
print("Denied")
})
break
default:
dispatch_async(dispatch_get_main_queue(), {
print("Default")
})
break
}
})
}
actionSheetController.addAction(choosePictureAction)
presentViewController(actionSheetController, animated: true, completion: nil)
}
I've already "cleaned" the project and reset the simulator settings, but still not getting the prompt to get displayed.