我正在使用异步下载的图像处理 ButtonRows,这是我的代码:
futurSection <<< ButtonRow("aaa") {
$0.title = ""
}.cellUpdate { cell, row in
cell.imageView?.imageFromServerURL("http://example.com/0x0ss2.jpg")
row.reload()
}.cellSetup({ (cell, row) -> () in
row.cell.height = {
return 150
}
})
我使用了 UIImageView 的扩展:
extension UIImageView {
public func imageFromServerURL(urlString: String) {
NSURLSession.sharedSession().dataTaskWithURL(NSURL(string: urlString)!, completionHandler: { (data, response, error) -> Void in
if error != nil {
print(error)
return
}
dispatch_async(dispatch_get_main_queue(), { () -> Void in
let image = UIImage(data: data!)
self.image = image
self.layoutSubviews()
if let myViewController = self.parentViewController as? ShowDetails {
myViewController.form.rowByTag("aaa")?.updateCell()
}
})
}).resume()
}}
但是在我单击该行本身之前,该行中的图像不会变得可见。我什至调用了 updateCell 并重新加载,但 id 不起作用。
谢谢!