사용자 지정 UITableViewCellAccessoryCheckmark가 필요한 테이블보기가 있습니다. 체크 표시는 행을 선택하면 표시되고 다른 행이 선택되면 마지막으로 선택한보기에 표시됩니다. 그건 잘 작동합니다.사용자 지정 UITableViewCellAccessoryCheckmark를 표시하는 방법
cell.accessoryView = [[ UIImageView alloc ]
initWithImage:[UIImage imageNamed:@"icon-tick.png" ]];
사용자 정의 UITableViewCellAccessoryCheckmark를 추가 :이 줄을 사용하는 경우
문제
가 발생합니다. 이 코드 다음에 UITableViewCellAccessoryCheckmark는 모든 행에 남아 있고 다른 행을 터치해도 사라지지 않습니다.- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
int index = indexPath.row; id obj = [listOfItems objectAtIndex:index];
UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath];
NSLog(@"%d",indexPath.row);
if (rowNO!=indexPath.row) {
rowNO=indexPath.row;
[self.tableView cellForRowAtIndexPath:indexPath].accessoryType=UITableViewCellAccessoryCheckmark;
cell.accessoryView = [[ UIImageView alloc ]
initWithImage:[UIImage imageNamed:@"icon-tick.png" ]];
[self.tableView cellForRowAtIndexPath:lastIndexPth].accessoryType=UITableViewCellAccessoryNone;
lastIndexPth=indexPath;
}
당신이 cicle에 대한이 링크는 또한 당신을 위해 유용 다른 모든 세포 –
사라를 위해 작성해야합니다 http://stackoverflow.com/questions/6359043/is-uitableviewcellaccessory 체크 표시가있는 이미지 –
이 링크는 또한 유용합니다. http://stackoverflow.com/questions/6359043/is-uitableviewcellaccessorycheckmark-an-image –