gpt4 book ai didi

iphone - 在我的 UITableView 中滚动时,返回时隐藏的行很奇怪

转载 作者:行者123 更新时间:2023-11-28 19:22:44 26 4
gpt4 key购买 nike

我的 UITableView 遇到了一些奇怪的问题。我有一个 Grouped TableView,每个部分有 1 行。每行都有一个文本字段。当我不被迫滚动时,一切都显示正确。

但是如果我必须滚动,之前隐藏的单元格就会乱七八糟。它们确实包含一个文本字段,但有许多文本标签相互重叠。

Cell http://dcsl.info/b/Untitled.png有什么建议吗?

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

// Configure the cell...
if(indexPath.section < [sectionArray count]) {
UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(20, 10,580, 31)];
textField.tag = indexPath.section + 22;
textField.autocorrectionType = UITextAutocorrectionTypeNo;
textField.autocapitalizationType = UITextAutocapitalizationTypeNone;
textField.delegate = self;
textField.text = [item.rechnerValues objectAtIndex:indexPath.section+1];

[cell.contentView addSubview:textField];
}
return cell;
}

最佳答案

这是因为您正在重复使用单元格。所以之前创建的 textFields 不会被删除。当您滚动时,您是在另一个上添加新的和新的。

解决方案:

  1. 删除之前创建的textFields
  2. (更好)只需将适当的 text 设置为已创建的文本字段

关于iphone - 在我的 UITableView 中滚动时,返回时隐藏的行很奇怪,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7307680/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com