IOS application crashes when user refuses permission on Photos after moving and scaling in UIImagePickerController

I use UIImagePickerController by default, with allowEditing set YES for shooting. When the user moves and scales the photo, the OS requests access to the "Photo". The application is disabled 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 the UIImagePickerControllerDelegate method looks 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]; } 

Failure Message:

 *** This application is not allowed to access Photo data. 

I wonder why he should first request access to photos. Any thoughts?

+7
ios ios8 uiimagepickercontroller
source share
1 answer

Use the Assets Framework to check if your application is allowed to access photo data.

  ALAuthorizationStatus status = [ALAssetsLibrary authorizationStatus]; if(status==ALAuthorizationStatusAuthorized) { ..your code... } 
+2
source share

All Articles