2012-01-31 6 views
0

Currenly私のcellForRowAtIndexPath関数では、私はセル内の値を保持する2つのUILabelsをサブクラス化しました。カスタムuilabel値に応じて特定のセルを無効にする方法はありますか?

とセルが無効に設定する必要があることを@"0,00"に等しいとした値2であれば、それはだ値2値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

関連する問題