【问题标题】:Expanding UITableViewCell扩展 UITableViewCell
【发布时间】:2012-04-30 12:34:49
【问题描述】:

我正在尝试扩展 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;
}

关于如何在单元格完成扩展后显示这些额外内容有什么想法吗??

谢谢!!

【问题讨论】:

    标签: ios xcode uitableview


    【解决方案1】:

    我遇到了完全相同的问题。解决方案是设置单元格的自动调整大小掩码,使其与父视图一起调整大小。

    cell.autoresizingMask = UIViewAutoresizingFlexibleHeight;
    cell.clipsToBounds = YES;
    

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

    【讨论】:

    • 您是否偶然找到了在第二次触摸时缩小单元格的方法?我正在想办法消除这种影响
    • 是的,只需将高度设置回最小高度就可以了。
    • 如果你的单元格从一开始就有动态高度怎么办?
    • 感谢主。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-08-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多