text in uitableviecell missing when scroll down
<p>I added several cells to a tableview and each cell has a textField in the right to let users input texts. I also added a custom cell class for this. I find that when I scroll down and go back, the input of the first few lines will disappear. Does anybody know what's the problem?</p>

<p>here is a piece of my code</p>

<pre><code>@implementation MyCell
-(void)setData:(NSString*)str 
{

  UIImage *image = [UIImage imageNamed:@"cellImage copy.png"];
  [[self imageView ]setImage:image];

  lblLocations=[[UILabel alloc]init];
  lblLocations.textAlignment=UITextAlignmentLeft;
  lblLocations.backgroundColor = [UIColor clearColor];
  lblLocations.font = [UIFont boldSystemFontOfSize:12];
   lblLocations.numberOfLines = 2;
  lblLocations.lineBreakMode = UILineBreakModeWordWrap;
  lblLocations.textAlignment = UITextAlignmentCenter;
   lblLocations.text =str ;
  NSLog(@"the title is%@",str);
  [[self contentView]addSubview:lblLocations];
  [lblLocations release];

  txtUnits=[[UITextField alloc]init];
    [txtUnits setAdjustsFontSizeToFitWidth:YES];
  txtUnits.textAlignment = UITextAlignmentCenter;

  txtUnits.returnKeyType = UIReturnKeyDone;
  txtUnits.autocapitalizationType = NO;
  txtUnits.textColor = [UIColor blackColor];
  if ([textDict valueForKey:[NSString stringWithFormat:@"%d",rowNum]]) {
    [txtUnits setText:[textDict valueForKey:[NSString stringWithFormat:@"%d",rowNum]]];
  }
  else
  {
    [txtUnits setPlaceholder:@"0.00"];
  }
  [txtUnits setValue:[UIColor blackColor] 
          forKeyPath:@"_placeholderLabel.textColor"];
  [[self contentView]addSubview:txtUnits];
  txtUnits.backgroundColor = [UIColor clearColor];
  txtUnits.delegate = self;
    [txtUnits release];
}
-(void)textFieldDidEndEditing:(UITextField *)textField
{
  [textDict setObject:textField.text forKey:[NSString stringWithFormat:@"%d",rowNum]]; 
}
</code></pre>

<p>and cellforrow....</p>

<pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
  static NSString *CellIdentifier = @"Cell";


  UITableViewCell *cell=nil;
  if (cell == nil) {
      cell = [[[MyCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier androw:[indexPath row]] autorelease];
  }
  cell.selectionStyle = UITableViewCellSelectionStyleNone;

  NSMutableDictionary *dict=(NSMutableDictionary*)[locations objectAtIndex:[indexPath section]];

  NSMutableArray *array=(NSMutableArray*)[dict objectForKey:@"locationsArray"];

  MyCell *modelObj=(MyCell*)[array objectAtIndex:indexPath.row];

  NSLog(@"the values of the array are%@",modelObj.title);
  NSString *str = modelObj.title;
  [(MyCell *)cell setData:str];
 return cell;
}
</code></pre>
