开发者

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜