Reusing cell doesn't work well - TableView

前端 未结 6 1878
余生分开走
余生分开走 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:09

    If you're using the click on the entire cell, you can override the setSelected func in your custom cell just like that.

    override func setSelected(selected: Bool, animated: Bool) {
         super.setSelected(selected, animated: animated)
         if selected {
             self.checkBook.image = UIImage(named: "check")
         } else {
             self.checkBook.image = UIImage(named: "uncheck")
        }
    }
    

提交回复
热议问题