친절하고 배우고 있습니다.체크 표시가있는 UITableView에서 여러 개의 탭이 필요합니다.
아래의 코드는 처음에 행을 탭한 후 (체크 표시가 적절하게 위치 함) 실제로 같은 체크 표시를 제거하기 위해 셀을 두 번 두드려야한다는 사실을 제외하고 실제로 실제로 잘 작동합니다.
마찬가지로 제거한 후 체크 표시를하려면 두 번 누릅니다.
어떻게 수정합니까?
- (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;
}
}
세포를 탭하면 didSelectRowAtIndexPath가 호출됩니까? 이 세포가 같은 물건에 속하는지 확인 했니? –