如何更新图像视图?

我从我的服务器抓取我的图像,从我的数据库抓取URL,并显示在我的自定义tableview单元格。

我使用下面的扩展名将url转换为图片。 正如你所看到的,它是asynchronous获取图像,但不显示图像。 我检查了url是否有效,但没有显示

在使用NSJSONSerialization获取我的数据之后,我做了一个

dispatch_async(dispatch_get_main_queue(), { self.tableView.reloadData() }) 

这是我在我的cellForRowAtIndexPath调用它

 override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { let cell:LatestPostCustomTableViewCell = tableView.dequeueReusableCellWithIdentifier("LatestPostCustomTableViewCell", forIndexPath: indexPath) as! LatestPostCustomTableViewCell cell.imagePost.downloadedFrom(link: latestPost[indexPath.row].imageURL, contentMode: .ScaleAspectFit) return cell } } 

我正在使用的扩展名从加载/下载从Swift的URL的图像检索

 extension UIImageView { func downloadedFrom(link link:String, contentMode mode: UIViewContentMode) { guard let url = NSURL(string: link) else {return} contentMode = mode NSURLSession.sharedSession().dataTaskWithURL(url, completionHandler: { (data, response, error) -> Void in guard let httpURLResponse = response as? NSHTTPURLResponse where httpURLResponse.statusCode == 200, let mimeType = response?.MIMEType where mimeType.hasPrefix("image"), let data = data where error == nil, let image = UIImage(data: data) else { return } dispatch_async(dispatch_get_main_queue()) { () -> Void in self.image = image } }).resume() } }