扩展UITableViewCell

Sea*_*ser 19 xcode uitableview ios

我正在尝试扩展UITableViewCell以显示更多内容.到目前为止,我已经关闭了动画,但我的问题是在动画完成之前出现了新内容.这是我的代码:

ps在配置单元格时,描述标签和读取按钮都以隐藏状态开始.

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    self.selectedRow = indexPath;
    SDJCell *cell = (SDJCell *)[tableView cellForRowAtIndexPath:indexPath];
    [tableView beginUpdates];
    [tableView endUpdates];
    cell.descriptionLabel.hidden = NO;
    cell.readButton.hidden = NO;
}

-(void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath {
    SDJCell *cell = (SDJCell *)[tableView cellForRowAtIndexPath:indexPath];
    [tableView beginUpdates];
    [tableView endUpdates];
    cell.descriptionLabel.hidden = YES;
    cell.readButton.hidden = YES;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    if(selectedRow && indexPath.row == selectedRow.row) {
    return 100;
    }
    return 44;
}
Run Code Online (Sandbox Code Playgroud)

关于如何在单元格完成后展示这些额外内容的任何想法?

谢谢!!

ary*_*axt 26

我有同样的问题.解决方案是设置单元格的自动调整遮罩,以便它与其超级视图一起调整大小.

cell.autoresizingMask = UIViewAutoresizingFlexibleHeight;
cell.clipsToBounds = YES;
Run Code Online (Sandbox Code Playgroud)

您也可以在sotoryboard中执行此操作,两个标志都可以在身份检查器下设置