I'm using UIImagePickerController to get image from device. I've implemented the following steps:
- Permission is taken: Privacy - Photo Library Usage Description - info.plist
Instance of UIImagePickerController is created and presented. Delegate is assigned to self. Camera or Library options are given with 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]; }On delegate, image has arrived but, when I tried to upload it to server after converting it into base64, the AFNetworking threw error:
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]; }
I tried creating OS_ACTIVITY_MODE to disable in environment variable, but it didn't work. I tried other solutions available but still it din't work. It was working fine but now it's not.