I am using the default UIImagePickerController with allowsEditing set to YES for taking photo. When the user moves and scales the photo, the OS asks for access to 'Photos'. The app crashes if the user denies access.
- (void)openCamera
{
UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];
imagePickerController.editing = YES;
imagePickerController.allowsEditing = YES;
imagePickerController.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePickerController.delegate = self;
[self presentViewController:imagePickerController animated:YES completion:nil];
}
And UIImagePickerControllerDelegate method goes like
- (void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
UIImage *image = info[UIImagePickerControllerEditedImage];
if (!image) {
image = info[UIImagePickerControllerOriginalImage];
}
self.profileImage = image;
[picker dismissViewControllerAnimated:YES completion:nil];
}
Crash message:
*** This application is not allowed to access Photo data.
I'm wondering why it should ask for access to Photos in the first place. Any thoughts?
Use Assets Framework to test if your app is allowed to access photo data.
ALAuthorizationStatus status = [ALAssetsLibrary authorizationStatus];
if(status==ALAuthorizationStatusAuthorized) {
..your code...
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With