扩展UITableViewCell [英] Expanding UITableViewCell

查看:71
本文介绍了扩展UITableViewCell的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am trying to expand a UITableViewCell to reveal more content. So far i've got the animation down, but my problem is the new content appears before the animation is complete. Here is my code:

ps配置单元格时,描述标签和读取按钮都是隐藏的。

ps the description label and read button both start off as hidden when the cell is configured.

-(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;
}

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

Any ideas for how I can reveal this extra content after the cell is done expanding??

谢谢!!

推荐答案

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

I had the exact same problem. The solution is to set the autoresizing mask of the cell, so that it resizes along with its superview.

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

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

you could also do this in sotoryboard, both flags can be set under identity inspector

这篇关于扩展UITableViewCell的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆