我的示例项目有一个注册表单。我在表格视图中设计了注册表单。它由八个文本字段组成,并在我输入数据时注册数据。但是,当我滚动视图时,注册表单视图文本字段中的数据会消失。
2 回答
            2        
        
		
你处理tableView:cellForRowAtIndexPath:错了。听起来您每次请求一个新单元格时都在创建一个新单元格(带有一个新的文本字段)。您必须存储每一行或整个单元格的文本字段,并在每次请求特定行时返回相同的字段。
于 2012-09-28T01:32:24.597   回答
    
    
            0        
        
		
//first allocate the view only cell is empty,and  assign values after if (cell == nil){} loop using tag
      - (UITableViewCell *)tableView:(UITableView *)tableview cellForRowAtIndexPath:(NSIndexPath *)indexPath {
         static NSString *CellIdentifier =@"Cell";
         UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
           if (cell == nil)
         {
           cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
             lable.frame=your frame;
            [cell.contentView addSubview :lable];
            titleLbl.frame=your frame;
            [cell.contentView addSubview :titleLbl];
                }
                        UILabel *titleLbl = (UILabel *)[cell viewWithTag:101];
                        UITextField *txtfield = (UITextField *)[cell viewWithTag:102];
                        titleLbl.text = @"";
    }
    于 2012-09-28T04:17:05.517   回答