Значение UILabel не обновляется в cellForRowAtIndexPath?

Я создаю пользовательские ячейки и обновляю некоторые UILabel каждый раз, когда появляется это представление.

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

       UILabel *lblFacingValue = nil;
       static NSUInteger const kFacingLabelTag = 7;

      CGFloat LeftLabelWidth = 130.0;

      static NSString *CellIdentifier = @"Cell";
      ClientState *clientState = [ClientState sharedInstance];
      UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

   if (cell == nil) 
   {
       cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];

       if(indexPath.row == 0)
       {
           lblFacingValue = [[[UILabel alloc] initWithFrame:CGRectMake(246, -11, LeftLabelWidth, (cell.contentView.frame.size.height))] autorelease];
           lblFacingValue.font = [UIFont systemFontOfSize:21];           
           lblFacingValue.textAlignment = UITextAlignmentLeft;
           lblFacingValue.backgroundColor = [UIColor clearColor];
           lblFacingValue.tag = kFacingLabelTag;        
           lblFacingValue.textColor = [UIColor yellowColor];
           [cell.contentView addSubview:lblFacingValue];
       }
    }
   lblFacingValue.text = [NSString stringWithFormat:@"%@", clientState.Direction];
}

Но проблема в том, что он содержит значение, которое я присваиваю впервые, и не обновляю его, когда открываю это представление. это представление находится на вкладке.

Он не обновлял значение lblFacingValue и пропускал проверку

if (cell == nil)

после первого раза. но не обновляйте lblFacingValue.

0
задан zakishaheen 25 October 2011 в 13:07
поделиться