【问题标题】:tableview cells bleeding though each other表格视图单元格相互流血
【发布时间】:2015-07-14 22:01:42
【问题描述】:

我有一个带有一个可重复使用单元格的 UITableview。可重复使用的单元格包含一张照片和一个标签。现在我的表格视图中有 7 个项目。加载后,一切都很好。但是当我向下滚动,然后再向上滚动时,细胞已经相互渗入。

这是我在 cellforRowatIndexPath 下的代码:

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
    let cell = tableView.dequeueReusableCellWithIdentifier("PostCell") as! PostTableCellView

    cell.imageView!.image = posts[indexPath.row].image.value


    let post = posts[indexPath.row]
    post.downloadImage()
    post.fetchLikes()
    cell.post = post

    cell.clipsToBounds = true
    cell.viewforphoto.clipsToBounds = true

    return cell
}

知道会发生什么吗?我现在已经重建了故事板,问题仍然存在。我还将图像视图和表格视图单元格的视图模式更改为宽高比、宽高比填充和比例填充。查看其他类似问题让我知道设置 clipstoBounds = true 是否有帮助,但没有。

【问题讨论】:

    标签: ios xcode swift uitableview


    【解决方案1】:

    问题是您正在下载cellforRowatIndexPath: 的中间位置。没有时间了。用户现在正在滚动。您必须现在返回单元格。 现在! 您不能远程获取数据或执行任何其他耗时的任务。您必须立即准备好每个请求单元格的数据。

    【讨论】:

    • 非常感谢!是的,这就是问题所在!我不知道为什么这被投了这么多票,但无论如何感谢您的帮助。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-03-07
    • 1970-01-01
    相关资源
    最近更新 更多