[英]iOS App crashes when user denies permission to Photos after Move & Scale in UIImagePickerController
我正在使用默認的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.
我想知道為什么它應該首先要求訪問照片。 有什么想法嗎?
使用資產框架測試您的應用是否可以訪問照片數據。
ALAuthorizationStatus status = [ALAssetsLibrary authorizationStatus];
if(status==ALAuthorizationStatusAuthorized) {
..your code...
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.