簡體   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