【问题标题】:How to change the height of UITableViewCell within that cell with UITableView with automatic dimension?如何使用具有自动尺寸的 UITableView 更改该单元格内 UITableViewCell 的高度?
【发布时间】:2015-08-05 07:50:02
【问题描述】:

到目前为止我尝试过:

@IBOutlet weak var requestDateButtonBottomConstraint: NSLayoutConstraint!

requestDateButtonBottomConstraint.constant = sender.selected ? 0 : 260

我也尝试过框架方法:

var cellFrame = self.frame
cellFrame.size.height = sender.selected ? 44 : 260
self.frame = cellFrame

没有人在工作......

【问题讨论】:

  • 你应该看看这个主题:stackoverflow.com/questions/18746929/… 这里几乎涵盖了关于动态UITableViewCell 高度的所有内容。
  • 所以您想将单元格内的内容更改为单元格的大小,使用 UITableViewAutomaticDimension 计算?
  • 是的,这正是我需要的

标签: ios swift uitableviewautomaticdimension


【解决方案1】:

只返回实际高度

UITableViewDelegate

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    if (something) {
        return 260.0
    } else {
        return UITableViewAutomaticDimension;
    }
}

【讨论】:

    猜你喜欢
    • 2016-08-16
    • 2017-04-27
    • 1970-01-01
    • 2020-10-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-07-22
    相关资源
    最近更新 更多