UITableView的内容高度 [英] UITableView content height

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

问题描述

我有一个被设置为不启用滚动的UITableView,它存在于UIScrollView中.我这样做是因为设计规范要求看起来像表格视图的东西(实际上有两个并排),实现表格视图比添加一堆按钮要容易得多. ,(分组表格视图).

I have a UITableView that is set to not enable scrolling, and it exists in a UIScrollView. I'm doing it this way as the design specs call for something that looks like a table view, (actually there are two of them side by side), and it would be much easier to implement tableviews rather than adding a whole bunch of buttons, (grouped table views).

问题是,我需要知道为滚动视图制作容器视图的大小,以便它滚动表视图的整个高度.加载后,是否有任何方法可以找到表格视图的高度?没有诸如滚动视图的contentView属性,框架似乎是静态的,等等.

Question is, I need to know how big to make the container view for the scrollview, so it scrolls the whole height of the table views. Once loaded, is there any way to find the height of a tableview? There is no contentView property like a scroll view, frame seems to be static, etc...

有什么想法吗?

推荐答案

使用

CGRect lastRowRect= [tableView rectForRowAtIndexPath:index_path_for_your_last_row];
CGFloat contentHeight = lastRowRect.origin.y + lastRowRect.size.height;

然后您可以使用contentHeight变量来设置scrollView的contentSize.

You can then use the contentHeight variable to set the contentSize for the scrollView.

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

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