내 iPhone 응용 프로그램에서 UITableView를 구현했습니다. 더 이상 나는 UITableView.But 행의 여러 선택을 추가 특정 행을 선택한 다음 테이블을 스크롤하고 unselected (표시가없는)에있는 각각의 행을 올 때. 내 didSelectRowAtIndexPath 메서드입니다.테이블 뷰에서 여러 행 선택
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[tableView deselectRowAtIndexPath:indexPath animated:YES];
if([tableView cellForRowAtIndexPath:indexPath].accessoryType==UITableViewCellAccessoryNone)
{
[tableView cellForRowAtIndexPath:indexPath].accessoryType=UITableViewCellAccessoryCheckmark;
[selectedIndexes addObject:[NSNumber numberWithInt:indexPath.row]];
NSLog(@"Select now %d",[selectedIndexes count]);
}
else if([tableView cellForRowAtIndexPath:indexPath].accessoryType==UITableViewCellAccessoryCheckmark)
{
[tableView cellForRowAtIndexPath:in dexPath].accessoryType=UITableViewCellAccessoryNone;
[selectedIndexes removeObject:[NSNumber numberWithInt:indexPath.row]];
NSLog(@"DeSelect now %d",[selectedIndexes count]);
}
}
해결책을 제공해주세요.
고마워. 내 cellForRowAtIndexPath 다음 줄을 추가하고 문제를 해결합니다 if ([selecte dIndexes containsObject : [NSNumber numberWithInt : indexPath.row]] \t { \t \t [cell setAccessoryType : UITableViewCellAccessoryCheckmark]; \t} – void