gpt4 book ai didi

向下滚动时 iPhone Storyboard 自定义单元格消失

转载 作者:行者123 更新时间:2023-11-29 11:01:28 25 4
gpt4 key购买 nike

我刚刚完成了一个项目,我在 Storyboard 中为我的 TableView 使用自定义单元格。

问题是,当我向下滚动时,每个单元格中的内容都消失了,在我的例子中是两个标签。

这是我用来呈现每个单元格的代码:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"CustomCell";
MessageCell *cell = (MessageCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];

if (cell == nil) {
cell = [[MessageCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}

Message *messageForRow = (Message *)[messages objectAtIndex:[indexPath row]];
[cell.messageLabel setText:[messageForRow message]];
[cell.senderLabel setText:[messageForRow sender]];

return cell;
}

我已经在 Storyboard中指定了正确的单元标识符并将类链接到我的自定义单元格类。

有什么问题吗?如果我遗漏了任何需要的信息,请告诉我。

最好的问候罗伯特

最佳答案

你能通过日志检查滚动时调用了这个方法吗?

关于向下滚动时 iPhone Storyboard 自定义单元格消失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15717428/

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