gpt4 book ai didi

当用户在 UIImagePickerController 中移动和缩放后拒绝对照片的权限时,iOS 应用程序崩溃

转载 作者:可可西里 更新时间:2023-11-01 03:33:42 25 4
gpt4 key购买 nike

我正在使用默认的 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.

我想知道为什么它首先要请求访问照片。有什么想法吗?

最佳答案

使用 Assets Framework 测试您的应用是否可以访问照片数据。

  ALAuthorizationStatus status = [ALAssetsLibrary authorizationStatus];

if(status==ALAuthorizationStatusAuthorized) {
..your code...
}

关于当用户在 UIImagePickerController 中移动和缩放后拒绝对照片的权限时,iOS 应用程序崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27912346/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com