我刚刚完成了一个项目,我在 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;
}
我在情节提要中指定了正确的单元格标识符,并将该类链接到我的自定义单元格类。
有什么问题?如果我错过了任何需要的信息,请告诉我。
最好的敬意罗伯特