Nazmul Hasan
Nazmul Hasan

Reputation: 10600

checkmark sign Tableview Automatic make

its one mandatory.the problem is the checkmark sign by default move down to 11 paces. so if you have 9 item in a list, you see that not happening with 9 item in a list. but if you have 30 item in a list, you will see 3 checkmark.but it should be one which one i have choice?.isSelect == true

if  choice?.isSelect == true {
  //this code execute one time              
  print("===========Checkmark=================")

  cell.accessoryType = .checkmark

}

One point out : tableview its reuse privious cell so if cell has already checked then 11th cell automatic checked. how can i fix?

Upvotes: 0

Views: 50

Answers (2)

Punit
Punit

Reputation: 1340

Just put else condition

if  choice?.isSelect == true {
    //this code execute one time              
    print("===========Checkmark=================")

     cell.accessoryType = .checkmark

  }else{
     cell.accessoryType = .none
    }

Upvotes: 1

NeverHopeless
NeverHopeless

Reputation: 11233

Perhaps due to re-usability previously added check mark remains on the cell. Try like this:

if  choice?.isSelect == true {
  //this code execute one time              
  print("===========Checkmark=================")

  cell.accessoryType = .checkmark

}
else
{
  cell.accessoryType = .none
}

Upvotes: 1

Related Questions