How do I observe cell accessory Type UITableViewCellAccessoryCheckmark is checked or not?
In my app I added UITableView in a UIAlertView. I also used
cell.accessoryType = UITableViewCellAccessoryCheckmark;
In my tableView, i have 9 rows. When the user taps on first row then all rows become checked except second row. The user can check any row/rows as he wishes. When the user taps on the second row then only the second row is checked.
Thanks in Advance 🙂
While the answer of @dasblinkenlight is certainly more elegant, it might be too advanced for you.
The essence is to keep track of which cells are checked and which are unchecked. Whenever something changes, reload the table view to updated the checkmarks.
You need to create your own variable to track this. A bitmap is very economical and elegant, but it might be difficult to understand and not scalable to a large number of rows. Alternatively, you could use an array.
To change a row given the index path:
And in
cellForRowAtIndexPathmake sure you set the accessory explicitly: