繁体   English   中英

当 property.allowsEditing 设置为 true 时,UIImagePickerController 返回右侧黑色背景的图像

[英]UIImagePickerController returns image with black background on right side when the property .allowsEditing is set to true

我正在使用 UIImagePickerController 从图库中挑选图像。 这是代码

let imagePicker = UIImagePickerController()
    imagePicker.sourceType = .photoLibrary
    imagePicker.allowsEditing = true
    imagePicker.delegate = self
    self.present(imagePicker, animated: true, completion: nil)


func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
    
    isfrompicker = true
    if let image = info[.editedImage] as? UIImage {
       // I'm getting image with black background on right side as shown.
    }
}

链接到图片

我不确定为什么我在右侧得到黑色背景。 相同的代码在某些设备上运行良好。 但是我的 iPhone X 出现了问题。

几年前我遇到了同样的问题。 然后我在链接到页面上找到了解决方案

在呈现 imagePicker 之前尝试添加此行

UINavigationBar.appearance().isTranslucent = true

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM