如何动态计算表高? [英] How to calculate table height dynamically?

查看:85
本文介绍了如何动态计算表高?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试动态计算UITableView的高度。我以为我可以在 func tableView(tableView:UITableView,cellForRowAtIndexPath indexPath:NSIndexPath) - >上做总结。 UITableViewCell ,问题是此方法仅针对第一个X单元格调用,并且在您滚动之前不会再为新集合调用。

I'm trying to calculate height for a UITableView dynamically. I thought I could do it doing the sum on func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell, the problem is that this method is only called for the first X cells and won't be called again for a new set until you scroll.

我正在使用autolayout约束,如何准确计算表格视图?

I'm using autolayout constraints, How can I calculate table view accuratelly?

推荐答案

我不确定你是什么尝试做但只是附加到你的评论你可以禁用滚动视图:

I am not sure what you are trying to do but appending to your comment you can disable scroll view with:

self.tableView.scrollEnabled = true 

你可以获得所有单元格的高度:

And you can get the hight of all the cells with:

self.tableView.contentSize.height 

这篇关于如何动态计算表高?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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