2012-05-04 59 views
0

enter image description hereUITextField进入UITableViewCell自动重置时向下滚动并返回?

enter image description here

enter image description here

我有更多的UITextFieldUITableViewCell但是当我向下滚动,我回头UITextField是空的。有一种不自动重置的方法?

这是代码:

-(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; 
} 

回答

3

它重新创建的细胞每次。这就是为什么每次创建新单元格并重新初始化包含控件时,如果UITextField包含文本,您可能没有放置条件,则不应清除其文本。

+0

我该怎么做? – user1053839

+0

你会发布你的代码cellForRowAtIndexPath:方法吗? –

+0

当然,我编辑的问题 – user1053839

相关问题