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



UIImagePickerController从照片库中选择/选择图像。我已允许UIImagePickerController编辑(选定(图像(裁剪图像的方形帧(,这适用于iPhone,但iPad无法提供正确编辑(裁剪(的图像。

我尝试了以下建议,但找不到解决方案:
iPad iOS7 - UIPopoverController 中的 UIImagePickerController 有错误的预览图像

这是我尝试过的代码:

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

添加此方法,您将获得准确的结果。

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

相关内容

  • 没有找到相关文章

最新更新