2013-10-16 2 views
-2

하나의 UITableview 및 UICutsom 셀이 있습니다. 해당 UITableview 웹 서비스를 사용하여 데이터를 채 웁니다. 셀의 배경색과 글꼴 색을 바꿉니다. 해당 Tableview 셀 배경색 및 레이블 색을 위아래로 스크롤하면 다른 셀에서도 변경됩니다.UITableview에서 UIScrollView 관련 문제가 발생했습니다.

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    static NSString *simpleTableIdentifier = @"FieldInventoryCell"; 

    // UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier]; 
    FieldInventoryCell *cell=(FieldInventoryCell *)[tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier]; 

    if (cell == nil) { 

     NSArray *nib=[[NSBundle mainBundle] loadNibNamed:@"FieldInventoryCell" owner:self options:nil]; 

     cell=[nib objectAtIndex:0]; 
    } 

    NSArray *ar = [[arr objectAtIndex:indexPath.row]componentsSeparatedByString:@"|"]; 
    cell.Status.text=[ar objectAtIndex:1]; 
    cell.serialnumber.text=[ar objectAtIndex:0]; 
    cell.date.text=[ar objectAtIndex:2]; 

    if([cell.serialnumber.text isEqualToString:@"Grand Total"]) 
    { 

     cell.contentView.backgroundColor=[UIColor blueColor]; 
     cell.serialnumber.textColor=[UIColor whiteColor]; 

    } 
    if ([cell.serialnumber.text isEqualToString:@"INV_FLD Status Total"]) 
    { 
     //cell.contentView.backgroundColor=[UIColor blueColor]; 
     cell.serialnumber.textColor=[UIColor orangeColor]; 

    } 


    return cell; 

} 
+1

실제 문제가 무엇인지 설명하지 않았거나 강조 표시했을 수 있습니다. 어떤 문제에 직면 해 있습니까? 무엇을 고치려고 했습니까? –

답변

0

귀하의 게시물에서 알 수있는 한, 발생한 문제는 셀을 대기열에서 제거하는 것과 관련되어 있습니다. contentView 및 일련 번호 레이블에 대해 몇 가지 색상을 설정 중이지만 조건이 충족되지 않으면 재설정하지 않습니다. 표가 셀을 재사용하므로 이미 색이 지정된 항목이 새 요소에 나타납니다. 문제를 해결하려면 색상을 기본값으로 다시 설정하십시오 (예 :

).
// ... 
if([cell.serialnumber.text isEqualToString:@"Grand Total"]) 
{ 

    cell.contentView.backgroundColor=[UIColor blueColor]; 
    cell.serialnumber.textColor=[UIColor whiteColor]; 

} else { 
    // reset color 
    cell.contentView.backgroundColor=[UIColor clearColor]; 
    cell.serialnumber.textColor=[UIColor blackColor]; 
} 

if ([cell.serialnumber.text isEqualToString:@"INV_FLD Status Total"]) 
{ 
    //cell.contentView.backgroundColor=[UIColor blueColor]; 
    cell.serialnumber.textColor=[UIColor orangeColor]; 

} else { 
    // reset color 
    cell.serialnumber.textColor=[UIColor blackColor]; 
} 
관련 문제