2012-10-31 5 views
0

내 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]); 
     } 
} 

해결책을 제공해주세요.

답변

1

프로그래밍 즐겨 위임 방법 cellForRowAtIndexPath 메소드가 모든 time..So이라고를 먼저 당신이 행을 저장해야 할 데이터마다 time.Means를로드 didSelectRowAtIndexPath 메소드에서 클릭하고 cellForRowAtIndexPath 메소드의이 행 인덱스에 따라 체크 표시가있는 표보기 행과 체크 표시가없는 나머지 행에 대해 표시해야합니다.

+0

고마워. 내 cellForRowAtIndexPath 다음 줄을 추가하고 문제를 해결합니다 if ([selecte dIndexes containsObject : [NSNumber numberWithInt : indexPath.row]] \t { \t \t [cell setAccessoryType : UITableViewCellAccessoryCheckmark]; \t} – void

0

이것을 확인하십시오. multiple-row-selection-and-editing

정말 쉽게 찾을 수 있습니다 & 유용한.

당신은 테이블 뷰마다 스크롤하는 동안

+0

감사합니다. .. – void