Code:
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *cellIdentifier = @"cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if(cell == nil){
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
cell.selectionStyle = UITableViewCellStyleDefault;
}
cell.contentView.backgroundColor = [UIColor clearColor];
cell.textLabel.text = @"testing";
if(indexPath.row == 1){
cell.textLabel.textColor = UIColorMake(kOrangeColour);
}
return cell;
} I가 storyboard.I 14 개 행이있는 tableview 내가 스크롤 .When 2 행 (IE1 인덱스)의 색상 변경 만들었고 많은 용의 tableview 아래가jQuery과 로우 색상 변경 스크롤 후
그때 나는 14 행 (ie 13 색인) 색상을 찾았습니다 .1 행과 14 행 모두 오렌지색입니다. 코드가 하나의 행 색상으로 변경되어야합니다. 왜 이런 현상이 발생합니까? 어떤 도움을 주시면 감사하겠습니다. 미리 감사드립니다.
스크롤하는 동안 UITableViewCells가 재사용되고 있습니다. 행이 1이 아닌 경우 레이블의 원본 textColor를 복원해야합니다. –