繁体   English   中英

另一个UItableview静态单元格内的静态UItableview

[英]Static UItableview inside another UItableview static cell

我有一个静态UItableview停留在一个静态UItableview单元中,但是即使我实现了以下功能,它也无法获得该单元的动态高度,

 func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
        return UITableViewAutomaticDimension
    }

    func tableView(tableView: UITableView, estimatedHeightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
        return UITableViewAutomaticDimension
    }

我在程序中错过了什么吗?

您应该在UITableViewCell使用约束。 如果添加了约束,并且您希望基于此约束的UITableViewCell的高度将以下内容添加到viewDidLoad

self.tableView.rowHeight = UITableViewAutomaticDimension;
// set estimatedRowHeight to whatever is the fallBack rowHeight
self.tableView.estimatedRowHeight = 44.0;

您无需实现tableView:heightForRowAtIndexPath:tableView:estimatedHeightForRowAtIndexPath:即可实现此目的。

检查是否在tableViewCell上添加了约束。 确保您不限制边距,并且元素在单元格的所有侧面都受限制。

我想摆脱的estimatedHeightForRowAtIndexPath方法,而是添加tableView.estimatedRowHeight = 100为例。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM