一覧のうち、一つだけをチェックするようなUITableViewのCheckmarkの更新をする際に、今までは選択したindexを変数として保持し、その都度TableをreloadDataしていたので
どうも動きがダサいなぁと思っていましたが、普通は多分こんな風にやるのですね。今更ですが。
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
for (int i = 0; i < [tableView numberOfRowsInSection:0]; ++i)
{
UITableViewCell *c = [tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:i inSection:0]];
c.accessoryType = UITableViewCellAccessoryNone;
if (i == indexPath.row) {
c.accessoryType = UITableViewCellAccessoryCheckmark;
}
}
}