我正在使用默认的UIImagePickerController,allowsEditing设置为YES,用于拍摄照片。当用户移动和缩放照片时,操作系统会请求访问“照片”权限。如果用户拒绝访问,则应用程序会崩溃。
- (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];
}
而UIImagePickerControllerDelegate的方法如下:
- (void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
UIImage *image = info[UIImagePickerControllerEditedImage];
if (!image) {
image = info[UIImagePickerControllerOriginalImage];
}
self.profileImage = image;
[picker dismissViewControllerAnimated:YES completion:nil];
}
崩溃信息:
*** This application is not allowed to access Photo data.
我想知道为什么首先要求访问照片。 有什么想法吗?