ロード後に最初のセルを確認すると、何も起こりません。何度も何度もタップしていますが、何も起こりません。他のセル、2 番目、3 番目などを確認でき、その後で初めて最初のセルを確認できます。これは私の方法です:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSUInteger row = indexPath.row;
NSUInteger oldRow = lastIndexPath.row;
if (oldRow != row) {
UITableViewCell *newCell = [tableView cellForRowAtIndexPath:indexPath];
newCell.accessoryType = UITableViewCellAccessoryCheckmark;
UITableViewCell *oldCell = [tableView cellForRowAtIndexPath:lastIndexPath];
oldCell.accessoryType = UITableViewCellAccessoryNone;
lastIndexPath = indexPath;
}
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
または、コードが多くて理解しにくいモデルだけを見つけたので、他の方法でそれを作成するようにアドバイスすることもできます (テーブルビューで 1 つのセルのみをチェックする)。