美文网首页
[Bug]Cell重用导致的内容加载混乱

[Bug]Cell重用导致的内容加载混乱

作者: iCHENKE | 来源:发表于2018-09-28 15:10 被阅读9次
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        var cell = tableView.cellForRow(at: indexPath)
        if cell == nil {
            cell = UITableViewCell(style:.default, reuseIdentifier: "cell")
        } else {
            while (cell?.contentView.subviews.last != nil) {
                cell?.contentView.subviews.last?.removeFromSuperview()
            }
        }
        //  其他操作...
        return cell!
    }

相关文章

网友评论

      本文标题:[Bug]Cell重用导致的内容加载混乱

      本文链接:https://www.haomeiwen.com/subject/ovrpoftx.html