Reusing cell doesn't work well - TableView

前端 未结 6 1869
余生分开走
余生分开走 2021-01-27 12:35

I have a problem about my cell\'s button. In my tableView each row is composed by: an image, some labels and a button. The button has a checkmark image. When it is clicked, the

6条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-27 13:03

    I faced this problem recently, and did not find much about it. What solve, after much searching, was to use:

    override func prepareForReuse() {
    
        btnAdd.setImage(nil, for: .normal) //here I use to change to none image
        super.prepareForReuse()
    } 
    

    just put this method inside your custom UITableViewCell, and set which item you want to realese stats.

提交回复
热议问题