Reputation: 1145
Even though I am not saving the photos anywhere but whenever I access the edited image in the didFinishPickingMediaWithInfo
function, iOS asks me for permission to access photos on the device.
Any idea how to prevent it from asking permission.
Adding UIImagePickerController
- (IBAction)addPhotoButtonPressed:(id)sender {
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.allowsEditing = YES;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.showsCameraControls = YES;
[self presentViewController:picker animated:YES completion:NULL];
}
didFinishPickingMediaWithInfo
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
[picker dismissViewControllerAnimated:YES completion:nil];
UIImage *image;
image = [info objectForKey:@"UIImagePickerControllerEditedImage"];
if (image == nil)
image = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
NSData *imageData = UIImageJPEGRepresentation(image, 0.05f);
_locationImage.image = [UIImage imageWithData:imageData];
imageFile = [PFFile fileWithName:@"Image.jpg" data:imageData];
}
Upvotes: 2
Views: 2268
Reputation: 50129
I don't see any way shy of writing your own editing control (which isn't that hard though) Then you have full control.
the UIImagePicker is asking that - I guess - because it saves the original image temporarily as if it were saved indeed...
Upvotes: 3
Reputation: 5065
you must know that when accessing the photo gallery for the first time the permission must be requested from the user.
Alo you must check the permission by
AVAuthorizationStatus authStatus = [AVCaptureDevice authorizationStatusForMediaType:mediaType];
if(authStatus == AVAuthorizationStatusAuthorized) {
// do your logic
} else if(authStatus == AVAuthorizationStatusDenied){
// denied
} else if(authStatus == AVAuthorizationStatusRestricted){
// restricted, normally won't happen
} else if(authStatus == AVAuthorizationStatusNotDetermined){
// not determined?!
[AVCaptureDevice requestAccessForMediaType:mediaType completionHandler:^(BOOL granted) {
if(granted){
NSLog(@"Granted access to %@", mediaType);
} else {
NSLog(@"Not granted access to %@", mediaType);
}
}];
} else {
// impossible, unknown authorization status
}
Upvotes: 0