UIImagePickerController cropping rect bug in iOS 11

When you create a UIImagePickerController with allowsEditing set to true, once the image has been obtained (either from the camera or the users photo library), it presents the image in a view with a cropping square to allow you to zoom and pan the are you would like the image to be cropped to.


In iOS 10.x this works fine. However, in iOS 11.x the cropping square is positioned too low in the view, such that the user thinks they are cropping a region lower than the they actually are. The effect is that the cropped image appears to be offset higer from what was apparently cropped.


When you compare iOS 10 to iOS 11, the fact that the cropping square is not vertically centered on the image is very clear. See screenshots below:


iOS 10, the image is clearly centered vertically in the cropping square:


iOS 11 (below you can clearly see the offset in the cropping square, meaning the image is positioned slightly above the center of the square)


The image returned in the UIImagePickerControllerDelegate.imagePickerController(_ picker:, didFinishPickingMediaWithInfo info:) in info[UIImagePickerControllerEditedImage] is offset down as a result, as the it returning the image that would have been in the cropping square had it been correctly positioned vertically. The info[UIImagePickerControllerCropRect] rect also returns the rect as if the cropping rect had been correctly positioned.


This has been reported as rdar://36292067 (not by me, but by the author of this Stack Overflow question explaining the same issue: https://stackoverflow.com/q/48056398/368085. A video demonstraing the issue is available here: https://www.dropbox.com/s/4csofidjcrc9ah6/UIImagePickerControllerEditedImageOffset.mp4?dl=0


A GitHub repo to demo the problem is here: https://github.com/aivars/photo-Picker-Tests. Again, these were all posted by Aivars Meijers, not myself. I'm just reposting the problem here in an effort to give it greater visibility as my team are also suffering from the same bug. There is no obvious workaround, other than not using "allowsEditing" when running on iOS 11, which is sub-optimal.

Replies

I'm facing the same issue. Any update on a futur fix?

It seems the inline images I added in my post were removed. Oh well. You just need to compare the position of the cropping square on iOS 10 vs iOS 11. On iOS 11 the square is clearly offset down, resulting in a crop that is higher than the user expected.

Facing the same issue. Any update on this?