错误域=插件套件代码=13 "查询已取消" UserInfo={NSLocalizedDescription=query cancel} 与目标 C Xcode 9.3 iOS 11



我正在使用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抛出了错误:

    错误域=插件套件代码=13 "查询已取消" 用户信息={NSLocalizedDescription=查询已取消} 与目标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以在环境变量中禁用,但它不起作用。我尝试了其他可用的解决方案,但仍然不起作用。它工作正常,但现在不是了。

答:( 确保对象选择图像不是零。 B:( 使用NSData *imageData = UIImageJPEGRepresentation(imageObject , 1)chosenImage转换为NSData。使用此图像数据作为您的NSUrlRequest正文。

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

相关内容

最新更新