Can any one please tell a code for unchecking a entire check marks in uitableview using a button click?

有帮助吗?

解决方案

Create an NSMutableArray in your tableView datasource class and in your cellForRowAtIndexPath method, add the checkboxes to the Array. (check for duplicate).

Then on button click, iterate the array and uncheck them.

其他提示

In didSelectRowAtIndexPath :

if (![myMutableArray containsObject:indexPath]) {
    [myMutableArray addObject:indexPath]; 
}
else{
    [myMutableArray removeObject:indexPath];
}

[sampleTableView reloadData];

And in cellForRowAtIndexPath :

if ([myMutableArray containsObject:indexPath]) {
    cell.accessoryType = UITableViewCellAccessoryCheckmark;
}
else{
    cell.accessoryType = UITableViewCellAccessoryNone;
}

And when button clicked, in that method remove the objects from this array and reload your tableView:

[myMutableArray removeAllObjects];
[sampleTableView reloadData]; 
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top