UitableViewCell과 관련된 문제가 있습니다. 문제는 내가 사용자 지정 셀을 만들었고 해당 셀에 확인란 이미지 단추가 있다는 것입니다. 나는 그것을 확인하고 선택을 취소한다. 그것은 잘 작동하지만 문제는 내가 행 # 1을 선택하면 행 # 10을 선택하는 것과 동일합니다. 2와 같은 다른 행이 자동 선택 행 # 11이됩니다. 한 번에 10 행을 표시하고 있습니다.사용자 지정 셀에서 uitableviewcell을 두 번 선택
여기 CellForIndexPath
static NSString *cellIdentifier = @"Cell";
InterestsTableViewCell *cell = (InterestsTableViewCell *) [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell==nil) {
NSArray *arrayNibs = [[NSBundle mainBundle] loadNibNamed:@"InterestsTableViewCell" owner:self options:nil];
cell = [arrayNibs objectAtIndex:0];
cell.delegate = self;
cell.total = [dataArray count];
}
cell.tag = indexPath.row;
cell.lblTitle.text = [dataArray objectAtIndex:indexPath.row];
if (indexPath.row==0) {
cell.imgBg.image = [UIImage imageNamed:@"tableCell_top_default.png"];
}else if(indexPath.row == [dataArray count]-1){
cell.imgBg.image = [UIImage imageNamed:@"tableCell_bottom_default.png"];
}else{
cell.imgBg.image = [UIImage imageNamed:@"tableCell_middle_default.png"];
}
return cell;
내 코드입니다 게다가 내가 배경 이미지를 (내가 배경으로 다른 이미지를 가지고) 변경할 수 있도록 내가 터치를 감지하고있다. 터치 시작 코드 (아래 사용자 지정 셀에 있음)
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
//NSLog(@"%i",tag);
isSelected = !isSelected;
btnTickMark.selected = !btnTickMark.selected;
(isSelected ? (onImage = YES) : (onImage = NO));
혹시이 문제에 도움을 주실 수 있습니다. 행을 클릭 할 때 2 행이 선택되는 이유를 누군가 도와 줄 수 있습니까?
미리 감사드립니다.
내가 어떤 종류의 수표인지 알 수 없습니까? – chsab420
"수표"는 if 절을 의미합니다. 나는 당신이 어딘가에있는 셀의 체크되거나 체크되지 않은 상태를 저장했다고 생각 하겠지요. 어쩌면 InterestsTableViewCell에서 직접 또는 dataArray에있을 수 있습니다. 그래서 "cell.lblTitle.text = [dataArray ..."를 사용하여 셀의 텍스트를 설정하는 것과 같이 모든 셀에 대해 선택되거나 선택되지 않은 상태를 설정해야합니다. –
고마워, 내가 해냈어. 다시 많은 감사드립니다. – chsab420