1
Bach顯示在.playground
文件中,但灰色。切換不同的Result Display Modes
沒有幫助。Swift 3遊樂場URLSession中的UIImage灰色異步
import UIKit
import PlaygroundSupport
PlaygroundPage.current.needsIndefiniteExecution = true
URLCache.shared = URLCache(memoryCapacity: 0, diskCapacity: 0, diskPath: nil)
var theImage = UIImageView()
let urlNew = NSURL(string: "https://upload.wikimedia.org/wikipedia/commons/6/6a/Johann_Sebastian_Bach.jpg")
let task = URLSession.shared.dataTask(with: urlNew! as URL) { (data, response, error) -> Void in
if error != nil {
print("thers an error in the log")
} else {
DispatchQueue.main.async() {
let image = UIImage(data: data!)
theImage.image = image
}
}
}
task.resume()
什麼是呈現巴赫或任何UIImageView
與雨燕3.0 .playground
的最佳方式?
你到目前爲止嘗試過什麼?很明顯,它正在下載適當的圖像,它可能只是遊戲場中的UI錯誤。您還應該能夠跳過'UIImageView'並直接顯示'UIImage'。 –
我試過了。將「UIImageView」中的代碼更新爲「UIImage」對灰色陰影沒有影響。 – Eric
我剛纔不在我的電腦前,但我會在今晚晚些時候重現問題。 –