swift - 滚动后表格 View 单元混合(快速)

标签 swift uitableview reuseidentifier

我制作了一个表格 View ,用一些数据填充单元格,效果很好。

问题是,当我滚动表格时,所有单元格都会混合,你知道有办法阻止这种情况吗?

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
    let celda = tabla_reportes.dequeueReusableCellWithIdentifier("celda", forIndexPath: indexPath) as! celdaReportes
    switch indexPath.section {
    case 0:
        celda.datos = tipos
        celda.back = UIColor.lightGrayColor()
    case 1:
        celda.index = indexPath.row
        celda.datos = fillArrayWithData(datos[indexPath.row] as! NSDictionary)
        celda.back = UIColor.clearColor()
    default:
        break
    }
    celda.delegate = self
    return celda
}

最佳答案

您应该更新单元格的字段。也许你在这里UITableViewCell reuse good practice可以帮助你

关于swift - 滚动后表格 View 单元混合(快速),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38491605/

相关文章:

objective-c - 将 Objective-C typedef 转换为 Swift 枚举后避免 "Interface type cannot be statically allocated"

iOS UIImageView作为UITableView背景,防止旋转

ios - 图像不适合 tableview 下的 imageview 框架,使用 AsynchImageView 从 URL 下载

arrays - 如何使用变量将字符串追加到数组中? swift

ios - MoPub 快速集成无法正常工作

iphone - UITableViewCell 文本很长

ios - 如何在 Storyboard Controller 中重用定义为原型(prototype)单元格的自定义 UITableViewCell

ios - 从可重用 Cell 出列时,自定义 CollectionViewCell 会触发什么方法?

ios - 自定义 tableviewcell 中的文本字段在滚动时超出单元格

ios - 使用 AVFoundation 捕获当前相机图像