开发者

UITableView Checkmark Selecting One At A Time

开发者 https://www.devze.com 2023-02-05 04:38 出处:网络
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 cou

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;
}
0

精彩评论

暂无评论...
验证码 换一张
取 消