ios - 错误域 = PlugInKit 代码 = 13 "query cancelled"UserInfo = {NSLocalizedDescription = 查询已取消} 与 Objective C Xcode 9.3 iOS 11

标签 ios objective-c uiimagepickercontroller

我正在使用 UIImagePickerController 从设备获取图像。我已经实现了以下步骤:

  1. 已获得许可: 隐私 - 照片库使用说明 - info.plist
  2. 创建并显示 UIImagePickerController 的实例。代表被分配给自己。相机或库选项由 UIAlertController 提供。

    -(void) openGallery {
        UIImagePickerController *picker = [[UIImagePickerController alloc] init];
        picker.delegate = self;
        picker.allowsEditing = YES;
    
        UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
    
        [actionSheet addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
        }]];
    
        [actionSheet addAction:[UIAlertAction actionWithTitle:@"Camera" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
            // take photo button tapped.
            picker.sourceType = UIImagePickerControllerSourceTypeCamera;
            [self presentViewController:picker animated:YES completion:NULL];
        }]];
    
        [actionSheet addAction:[UIAlertAction actionWithTitle:@"Photo Library" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
            // PhotoLibrary
            picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
            [self presentViewController:picker animated:YES completion:NULL];
        }]];
    
        [self presentViewController:actionSheet animated:YES completion:nil];
    }
    
  3. 在代理上,图像已经到达,但是当我尝试将其转换为 base64 后上传到服务器时,AFNetworking 抛出错误:

    Error Domain=PlugInKit Code=13 "query cancelled" UserInfo={NSLocalizedDescription=query cancelled} with Objective C Xcode 9.3 iOS 11

    #pragma mark- UIImagePicker Delegate
    
    - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary<NSString *,id> *)info{
        UIImage *chosenImage = info[UIImagePickerControllerEditedImage];
    
        [picker dismissViewControllerAnimated:YES completion:NULL];
    
        [self.view setUserInteractionEnabled:NO];
        [self uploadThemeServiceCall: chosenImage];
    }
    

我尝试创建 OS_ACTIVITY_MODE 以在环境变量中禁用,但没有成功。我尝试了其他可用的解决方案,但仍然没有用。它工作正常,但现在不行了。

最佳答案

A:) 确保对象 selectedImage 不为零。 B:) 使用 NSData *imageData = UIImageJPEGRepresentation(imageObject , 1)chosenImage 转换为 NSData 。使用此 imageData 作为您的 NSUrlRequest 正文。

另请在此处显示函数 uploadThemeServiceCall 的代码。

关于ios - 错误域 = PlugInKit 代码 = 13 "query cancelled"UserInfo = {NSLocalizedDescription = 查询已取消} 与 Objective C Xcode 9.3 iOS 11,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52203204/

相关文章:

ios - 缺少 iCloud 日志记录 "Using local storage: 0"

objective-c - UITableViewCell 中的 UISegmentedControl 在通过 dequeueReusableCellWithIdentifier 重用时更改段索引顺序

iphone - 低内存会阻止显示模态视图 Controller 吗?

ios - 如何知道 UIView 的当前比例?

ios - 可以从 Lion 上传到 App Store 吗?

iphone - TBXml 空标记文本

ios - 'sharedApplication' 不可用 : not available on iOS (App Extension)

ios - 为什么 awakeFromNib 从 TableView 中的 Cell 调用两次?

ios - 4 :3 instead of 16:9 (Xcode) (Swift) 调用UIImagePickerController

iphone - UIImagePickerController mediaTypes kUTTypeMovie 导致 NSCFNumber 中出现少量内存泄漏