UITableView Checkmark Selecting One At A Time
I have a UITableView, and when a cell is pressed, a checkmark is displayed in the accessory view. However I want to only be able 开发者_Go百科to have one checkmark displayed at any given time. How could I do that?
Depends on how you are comparing your data. This is how I use checkmarks for my tableView:
if([[plistDict objectForKey:@"Warranty"] boolValue] == YES) {
cell.accessoryType = UITableViewCellAccessoryCheckmark;
} else {
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
You can also compare text:
if([cell.textLabel.text isEqualToString:@"Some Text"]) {
cell.accessoryType = UITableViewCellAccessoryCheckmark;
} else {
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
精彩评论