I am developing an iPhone application with UITableView. I have implemented a check mark on each cell with didSelectRowAtIndexPath delegate.
Now I want to select a cell that disable all other cells (remove the check marks) and vice versa (eg: to select 8th cell that shows the check mark on 8th cell and remove the check mark of other cells, then select other cell shows the check mark on that cell and remove the check mark on 8th cell).
How to implement this in UITableView?
You can achieve this by adding these two ivars to your UITableViewController class to track which cell is currently checked:
In your initialize method, set
currentlyCheckedRowandcurrentlyCheckedSectionto a negative integer such as-1so that it is not matched by any possible row value.Add the following to your
-tableView:cellForRowAtIndexPath:method:Update the
currentlyCheckedRowivar when-tableView:didSelectRowAtIndexPath:is called: