I have UIImagePickerController
to select/pick an image from the photo gallery. I have allowed UIImagePickerController to edit (selected) image (crop square frame of image), which works fine with iPhone but iPad can't provide properly edited (cropped) image.
I tried the following suggestion but could not find a solution:
iPad iOS7 - UIImagePickerController in UIPopoverController has wrong preview image
Here is code, that I've tried:
let imagePicker = UIImagePickerController()
imagePicker.allowsEditing = true
// Update (zoom) visibility of image using pinch gesture & retrieve image using delegate - didFinishPickingMediaWithInfo
//------------------------------------------
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
if let pickedImage = info[UIImagePickerControllerEditedImage] as? UIImage {
// Wrong image - retrieves image different than actual visible in the editing window of picker view.
}
if let pickedImage = info[UIImagePickerControllerOriginalImage] as? UIImage {
// Original image, visible perfect in iPad, when imagePicker.allowsEditing = false
}
picker.dismiss(animated: true) {
// dismissing image picker
}
}
Add this method , you will get accurate result.
func navigationController(_ navigationController: UINavigationController, didShow viewController: UIViewController, animated: Bool) {
UIApplication.shared.isStatusBarHidden = true
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With