2012-01-31 3 views
0

Currenly 내 cellForRowAtIndexPath 함수에서 나는 세포 내부의 값을 보유하고있는 두 개의 UILabels을 서브 클래 싱했습니다.사용자 정의 uilabel 값에 따라 특정 셀을 비활성화하는 방법은 무엇입니까?

세포가 비활성화 설정 될 필요가 있다고 @"0,00"에 동일하고이 값이 경우 그것의 값이 값 1

입니다 값이 하나 개의 셀에 관한 것으로, 예를 들어 말할 수 있습니다 cell.accessoryType 세트

-(UItableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
     { 

      UITableViewCell *cell = [myTableView dequeueReusableCellWithIdentifier:CellIdentifier]; 

      if (cell == nil) 
      { 
      cell = [self getCellContentView:CellIdentifier]; 
      } 

      UILabel *lblValues = (UILabel *)[cell viewWithTag:1]; 

      UILabel *lblsecValues = (UILabel *)[cell viewWithTag:2]; 

      lblvalues.text = [values objectAtIndex:indexPath.row]; 

      lblsecValues.text = [secValues objectAtIndex:indexPath.row]; 


      cell.accessoryType = UITableViewAccessoryDisclosureIndicator; 


      /* 
      if ( something.....){ 

       //cell holding the `@"0,00"` 
       //cell.accessoryType = UITableViewAccessoryNone; 

       //cell.setUserInteractionEnabled = NO; 


      } 
      */ 
      return cell;    

     } 

None에 대한 모든 팁 및/또는 직업을 찾을 수있는 방법을 제안 조건 당 매우 높게 평가 될 것입니다. 미리 감사드립니다.

답변

2

다음 코드를 마법처럼

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    UITableViewCell *cell = [myTableView dequeueReusableCellWithIdentifier:CellIdentifier]; 

    if (cell == nil) 
    { 
     cell = [self getCellContentView:CellIdentifier]; 
    } 

    UILabel *lblValues = (UILabel *)[cell viewWithTag:1]; 
    UILabel *lblsecValues = (UILabel *)[cell viewWithTag:2]; 

    lblvalues.text = [values objectAtIndex:indexPath.row]; 
    lblsecValues.text = [secValues objectAtIndex:indexPath.row]; 

    if([[secValues objectAtIndex:indexPath.row] isEqualToString:@"0,00"]) 
    { 
     cell.accessoryType = UITableViewAccessoryNone; 
     cell.userInteractionEnabled = NO; 
    } 
    else 
    { 
     cell.accessoryType = UITableViewAccessoryDisclosureIndicator; 
     cell.userInteractionEnabled = YES; 
    } 

    return cell;    
} 
+0

작품을 사용합니다. 고마워! – doge

관련 문제