2011-08-27 1 views
0

각 섹션의 5 섹션 및 가변 개수의 행이있는 사용자 정의 셀 (셀의 이미지 확인 및 선택 취소)이있는 테이블 뷰가 있습니다. 첫 번째 섹션에서 행을 선택하면 tableview는 마지막 섹션의 행 중 하나를 선택합니다.눈금 표시 및 셀 재로드에 관한 UITableView 문제

위아래로 스크롤하면 확인 된 행이 섹션에서 임의로 이동합니다.

문제는 테이블 뷰에서 하나의 섹션을 제거 할 때 문제가되지 않는다는 것입니다. 나. 심지어 섹션 수.

아무도 도와 줄 수 있습니까?

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    static NSString *kCustomCellID = @"MyCellID"; 
    CustomCell *cell = (CustomCell *)[tableView dequeueReusableCellWithIdentifier:kCustomCellID]; 
    if (cell == nil) 
    { 
     cell = (CustomCell *) [[[CustomCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:kCustomCellID]autorelease]; 
    } 

이것이 내가 사용한 코드입니다.

나는 어딘가에서 실수를했을 것이다. 그러나 나는 그것을 발견 할 수 없다.

+0

에 지정된

가 올바르게 세포를 재사용하고 있습니다. 'tableView : cellForRowAtIndexPath :'를 게시 해 주시겠습니까? 문제가 있다는 느낌이 강합니다. –

답변

0

테이블의 셀을 재사용하기 때문에 테이블 재사용 방법론에 대해 자세히 읽어보십시오. 자세히 보려면 ​​셀을 볼 수있는 셀에 다시 사용하므로 셀의 변경 내용이 다른 셀로 복사됩니다.

0

적절하게 문제를 진단하려면 코드 (특히 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 구현)가 필요합니다. 나는 때 재사용 세포에 뭔가 문제가 있다고 생각 apples docs

static NSString *cellIdentifier = @"MyAwsomeCell"; 

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 

if (cell == nil) { 
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier] autorelease]; 
}