優しくして、私は学んでいます。
以下のコードは、最初に行をタップした後(適切にチェックマークを付ける)、同じチェックマークを削除するためにセルを2回タップする必要があるという事実を除いて、実際には正常に機能します。
同様に、それを削除した後、チェックマークを元に戻すには2回タップする必要があります。
これを修正するにはどうすればよいですか?
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *thisCell = [tableView cellForRowAtIndexPath:indexPath];
NSInteger selectedRow = indexPath.row;
if (thisCell.accessoryType == UITableViewCellAccessoryNone) {
thisCell.accessoryType = UITableViewCellAccessoryCheckmark;
if (selectedRow == 0) dm = 1;
else if (selectedRow == 1) athero1 = 1;
else if (selectedRow == 2) athero2 = 1;
else if (selectedRow == 3) athero3 = 1;
else if (selectedRow == 4) familyHistory1 = 1;
else if (selectedRow == 5) familyHistory2 = 1;
}
else {
thisCell.accessoryType = UITableViewCellAccessoryNone;
if (selectedRow == 0) dm = 0;
else if (selectedRow == 1) athero1 = 0;
else if (selectedRow == 2) athero2 = 0;
else if (selectedRow == 3) athero3 = 0;
else if (selectedRow == 4) familyHistory1 = 0;
else if (selectedRow == 5) familyHistory2 = 0;
}
}