0

I have used this below code to open UIImagePickerView.

 UIImagePickerController *picker = [[UIImagePickerController alloc] init];
 picker.delegate = self;
 picker.allowsEditing = YES;
 picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
 [self.view presentViewController:picker animated:YES completion:nil];

I have just get cropped image from didfinish method of UIImagePicker but as I have attached image it's providing this image.

As you can see i have allowing editing of photo.

Now See Image what i crop and what this UIImagePickerView returning to me.

enter image description hereenter image description here

Hardik Vyas
  • 1,973
  • 1
  • 20
  • 43
  • [self.view presentViewController:picker animated:YES completion:nil]; instead of use like this [self presentViewController:picker animated:YES completion:nil]; and didfinish like this - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { UIImage *selectedImage = [info objectForKey:UIImagePickerControllerOriginalImage]; self.selectedImgView.image = selectedImage; [picker dismissViewControllerAnimated:YES completion:nil]; } and its working fine for me – Rajesh Dharani Aug 30 '18 at 11:23
  • @RajeshDharani this is impossible to read. If you're answering a question... add an answer. Not a comment. – Fogmeister Aug 30 '18 at 11:37
  • @RajeshDharani i am using mostly same code no change same response. – Hardik Vyas Aug 30 '18 at 11:38
  • 1
    Is it the same issue as here? https://stackoverflow.com/questions/12630155/uiimagepicker-allowsediting-stuck-in-center – Fogmeister Aug 30 '18 at 11:39
  • No @Fogmeister it's different issue. – Hardik Vyas Aug 30 '18 at 12:06
  • You can try this: https://github.com/myang-git/iOS-Image-Crop-View – Faysal Ahmed Aug 30 '18 at 12:36
  • @hardikvyas check content aspect mode of UIImageView. – Anand Kore Aug 31 '18 at 09:56
  • @AnandKore Actually i have tested and check it before set to uiimageview it's giving wrong image and this issue i have found all app which developed in latest version please check it in your current app also it may be there in your app also. – Hardik Vyas Sep 05 '18 at 07:15

1 Answers1

-2

So I think you want to cropped this image when set allowEditing YES.

If you don't want to edited this image, set allowEditing property NO.

When you get or edited this image,you need make this image in UIPickerViewControllerDelegate .Next method,

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary<NSString *,id> *)info

In this delegete method, you need to write code like this.

    [picker dismissViewControllerAnimated:YES completion:^{}];

    // edit image -- select type UIImagePickerControllerEditedImage
    // origin image --  UIImagePickerControllerOriginalImage
    UIImage *generateImg = [info objectForKey:UIImagePickerControllerOriginalImage];

    //and then operate this image. 

You can try and test if the issue is resolved.If not you can ask again in here.

Jaeda
  • 32
  • 4
  • So you need change UIPickerViewControllerDelegate info ,set UIImagePickerControllerEditedImage.This question that capture image move up wnen tap choose UIButton. – Jaeda Aug 31 '18 at 01:51
  • 1
    I passing a lot of testing when you post this question .Finally,I found the problem occured in system version over 11.0.When system version 11.0 or less,it's ok.I test in 11.3 and 10.3.So I think it because of system version in over 11.0.You can believe me or test yourself. – Jaeda Aug 31 '18 at 02:00
  • It's actually system issue i have tested in other app also at there and found there is same issue. – Hardik Vyas Aug 31 '18 at 05:44