加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ios – 扩展UITableViewCell

发布时间:2020-12-15 02:02:56 所属栏目:百科 来源:网络整理
导读:我试图扩大一个UITableViewCell以显示更多的内容。到目前为止,我已经有了动画,但我的问题是动画完成之前出现的新内容。这是我的代码: 在配置单元格时,描述标签和读取按钮都开始隐藏。 -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPat
我试图扩大一个UITableViewCell以显示更多的内容。到目前为止,我已经有了动画,但我的问题是动画完成之前出现的新内容。这是我的代码:

在配置单元格时,描述标签和读取按钮都开始隐藏。

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

任何想法,我怎么可以揭示这个额外的内容,在细胞完成扩张后?

谢谢!!

解决方法

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

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

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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读