Reputation: 390
I have more UITextField
into UITableViewCell
but when I scroll down and I turn back the UITextField
is empty. There is a way for not auto reset?
This is the code:
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cella"];
if(cell==nil){
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cella"];
}
cell.textLabel.text = [dati objectAtIndex:indexPath.row];
UITextField *testo = [[UITextField alloc] initWithFrame:CGRectMake(0, 0, 150, 31)];
testo.borderStyle = UITextBorderStyleRoundedRect;
testo.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
testo.placeholder = @"Inserisci del testo..";
testo.delegate = self;
cell.accessoryView = testo;
return cell;
}
Upvotes: 0
Views: 902
Reputation: 5183
It's re-creating the cell every time. That is why every time it is creating new cell and reinitialize contained controls where you might not have put condition if a UITextField contains text, it should not clear its text.
Upvotes: 3