gpt4 book ai didi

ios - 自定义 UITableViewCell 在 UITableView 中没有复用?

转载 作者:行者123 更新时间:2023-11-29 11:15:21 24 4
gpt4 key购买 nike

我有一个 UITableViewControllerUITableViewCell。该单元格包含三个文本字段。每个文本字段都有一个标签。单元格创建如下。

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"reuseMyCell";

cell = (TimeInserTableViewCell *) [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {

NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"TimeInsertCell" owner:self options:nil];

for (id currentObject in topLevelObjects){

if ([currentObject isKindOfClass:[TimeInserTableViewCell class]]){
cell = (TimeInserTableViewCell *) currentObject;
if ([cell.reuseIdentifier isEqualToString: CellIdentifier]) {

break;
}

}
}
}

cell.taskNameField.delegate=self;
cell.startTime.delegate=self;
cell.endTime.delegate=self;

return cell;
}

我的问题如下:当我在第一个文本字段中输入文本并滚动时,之前的文本字段文本也在其他单元格中被替换。

最佳答案

检查您是否在自定义单元 IB 中使用重用标识符。

关于ios - 自定义 UITableViewCell 在 UITableView 中没有复用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9717197/

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