【问题标题】:UITextField text in UITableViewCell auto reset when scroll down and turn back?向下滚动并返回时,UITableViewCell 中的 UITextField 文本会自动重置吗?
【发布时间】:2013-04-19 11:20:57
【问题描述】:

我有一个带有多单元格的 uitableview。其中包含文本文件,当我在文本字段上输入文本并滚动表格视图时,输入的文本正在擦除 我的代码是

    static NSString *CellIdentifier = @"Cell";

        ComplaintsCustomCell *cell=(ComplaintsCustomCell*)[tableView dequeueReusableCellWithIdentifier:nil];        
        if(cell==nil){
            NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"ComplaintsCustomCell" owner:self options:nil];

            for(id currentObject in topLevelObjects){

                if([currentObject isKindOfClass:[UITableViewCell class]]){
                    cell = (ComplaintsCustomCell *) currentObject;
                    break;
                }
            }
        }
        cell.selectionStyle=UITableViewCellSelectionStyleNone;

        NSDictionary *dict=[array1 objectAtIndex:indexPath.row];
        cell.complaintID_label.text=[dict valueForKey:@"ProblemName"];

        if(cell.notesView!=nil)
        cell.notesView.text=[dict valueForKey:@"Notes"];
           [cell.notesView setTag:indexPath.row +6000];

        cell.durationFld.text=[dict valueForKey:@"Duration"];
        [cell.durationFld setTag:indexPath.row + 5000];
        cell.durationFld.delegate=self;

【问题讨论】:

  • 你的 UITextFieldDelegate 方法在哪里?

标签: objective-c xcode uitableview uitextfield


【解决方案1】:

您的类还需要成为每个文本字段的代表,检测每个文本更改并更新关联的模型对象(您的字典数组)。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-03-27
    相关资源
    最近更新 更多