ios – UIImagePickerController编辑的图像在iPad中检索错误的图像

我有UI ImagePickerController从照片库中选择/选择一个图像.我已经允许UIImagePickerController编辑(选中)图像(裁剪图像的方框),这适用于iPhone,但iPad无法提供正确的编辑(裁剪)图像.

我尝试了以下建议,但找不到解决方案:
iPad iOS7 – UIImagePickerController in UIPopoverController has wrong preview image

这是代码,我尝试过:

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 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
    }

}

最佳答案 添加此方法,您将获得准确的结果.

func navigationController(_ navigationController: UINavigationController, didShow viewController: UIViewController, animated: Bool) {
    UIApplication.shared.isStatusBarHidden = true
}
点赞