1

EDIT: This was closed as an exact duplicate of UIImagePicker allowsEditing stuck in center , but that seems to be totally different question. That question is concerned with the user being unable to move the crop box (with the extra weirdness that it only happens for the camera). This question is about the image picker returning the wrong value into my code.

I have allowsEditing = true on my UIImagePickerController, thus allowing images to be cropped:

enter image description here

The image that comes out in info[UIImagePickerControllerEditedImage] always looks generally right and is cropped, but it's as if the crop window has been slid upward by ~10%:

enter image description here

You can see above that the crop window cut through the leaf's midrib, but in the output of the picker, the midrib is totally visible.

Anyone familiar with this behavior?

Cannoliopsida
  • 3,044
  • 5
  • 36
  • 61
  • @Fogmeister : I see you marked this as a exact duplicate of https://stackoverflow.com/questions/12630155/uiimagepicker-allowsediting-stuck-in-center , but that seems like a totally different question. Am I missing the connection? Or are you saying that this is also caused by an iOS bug? – Cannoliopsida Jan 05 '18 at 20:14

2 Answers2

2

Yes, Same issue i've faced , now got the solution , you why its image takes -10% from image? because our status bar is shown in our Project , it will contains its height , u need to hide that by putting below method , u will get accurate result.

func navigationController(_ navigationController: UINavigationController, didShow viewController: UIViewController, animated: Bool) {
    UIApplication.shared.isStatusBarHidden = true
}
NIRAV BHAVSAR
  • 152
  • 12
1

The Status Bar is messing it up as Nirav Bhavsar said.

His solution didn't work for me but adding the following extension worked to make the UIImagePickerControllerEditedImage correctly crop the image.

extension UIImagePickerController {
    open override var childViewControllerForStatusBarHidden: UIViewController? {
        return nil
    }

    open override var prefersStatusBarHidden: Bool {
        return true
    }
}

This extension hides the status bar in UIImagePickerController which looks a little weird but the result is all that matters.

I got it from Swift 3.0 - how to hide status bar after calling UIImagePickerController?

siefix
  • 916
  • 1
  • 10
  • 19