Boris-Em/BEMCheckBox

Duplicate issue when use it as a view inside a prototype UITableViewCell

Closed this issue · 4 comments

hello,
a strange behavior when i use BEMCheck as a view inside a cell in UITableView!

rendering is very nice, but the problem is: when i check BEM in row no "1", another BEM checked in row No "10" automatically!!! (while i don't implement any action on touch event!)

i'm using Xcode8 with Swift3
note that i put BEMCheckBox inside a prototype UITableViewCell like following:
ViewController -> UITableView -> UITableViewCell -> View (BEMCheckBox)

any suggestion guys?

Regards

Might this be a popular problem with tableView dequeuing cells? Try setting cell's checkbox to OFF state like so:

    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath)
        cell.checkBox.setOn(false, animated: true)
        
        return cell
    }

This issue doesn't seem related to BEMChcekBox, but more with your implementation of UITableView, and more specifically the way you reuse cells. Please provide more context if you need help!

thanks guys,

after many tries, really it doesn't related to BEMCheckBox!

just add this function to the cell class:

override func prepareForReuse() { super.prepareForReuse() //set cell to initial state here: cell.checkBox.setOn(false, animated: false) }

When didTap() is called .How to find its row & sections. If it is row alone we can use the tag property. But in my scenario ,I have both row and section . I have didSelect() of tableview.But didSelect is not called alltimes