ios - 如何在后台加载图像时继续用文本填充表格视图单元格
问题描述
我从存储在数组中的 api 读取两个属性(名称和图像)。我知道如何在表格中显示它们,但我不知道如何在显示名称后制作表格移动到下一行而不等待加载图像。我想在后台加载图像并在完成后显示它。
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("customcell", forIndexPath: indexPath) as! UITableViewCell
//when i get text move on next cell not waiting for image to be loaded
cell.textLabel?.text = myarray[indexPath.item].name
//make this image loading in background
cell.imageView?.image = myarray[indexPath.item].image
return cell
}
解决方案
推荐阅读
- c# - 使用asp.net web api在服务器webfolder上上传文件并同时发布json数据
- java - Android Studio 不会自动启动应用程序
- javascript - Vuex,firestore:显示过滤结果
- r - purrr::map 使用纯素函数(poolacuum)时不循环组
- awk - 如何使用 awk 计算总和并替换文件中的列
- angular - Angular 材质组件不适用于我的项目
- publish-subscribe - Supply method act 与 tap 之间的区别
- html - 将父级的背景图像拉伸到伪元素?
- android - 自 RewardedVideoAdListener 被弃用以来,libgdx 如何实现 admob 奖励视频
- android - 迁移到 AndroidX 后无法更改配置“:编译”的依赖关系