【发布时间】:2017-02-15 03:07:41
【问题描述】:
我有一个这样的函数:
fileprivate func setupImageViewWithURL(url: URL) {
var image: UIImage? = nil
do {
try image = UIImage(data: Data(contentsOf: url))!
} catch is NSError {
print("Failed")
}
image = self.imageWithImage(sourceImage: image!, scaledToWidth: UIScreen.main.bounds.size.width)
self.imageImageView.image = image
self.imageImageView.frame = CGRect(x: 0, y: 0, width: UIScreen.main.bounds.size.width, height: (image?.size.height)!)
}
我想在 Background thread 上运行它。
我尝试了Swift2的GDC方法,但是没有用。
Swift3 中的主题有什么变化吗?
谢谢!
【问题讨论】:
-
@New16 我已经试过了,它甚至不符合
-
@FS.O6 我在我的代码中使用它。我不知道你是如何实现它的。显示您遇到的错误。
-
你不想在后台线程上运行它。 UI 更新不应该在后台线程上执行。
标签: ios iphone swift cocoa-touch swift3