使UITableView不可滚动并调整高度以容纳所有单元格 [英] Make UITableView not scrollable and adjust height to accommodate all cells
本文介绍了使UITableView不可滚动并调整高度以容纳所有单元格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在另一个 UIScrollView
中嵌入了 UITableView
。我只想要 UIScrollView
滚动,而不是 UITableView
,所以我想禁用<$ c $中的滚动c> UITableView ,以及为 UITableView
扩展 contentHeight
以适应所有动态一次。
I'm embedding a UITableView
inside of another UIScrollView
. I only want the UIScrollView
to scroll, not the UITableView
, so I want to disable the scrolling in UITableView
, as well as expand the contentHeight
for the UITableView
to accommodate all dynamic at once.
我该如何做呢?
推荐答案
您需要将 UITableView
滚动到 false
,
tableview.scrollEnabled = false;
tableview.frame = CGRectMake(tableview.frame.origin.x, tableview.frame.origin.y, tableview.frame.size.width, tableview.frame.size.height+(resultArray.count*HEIGHT_OF_CELL));
然后你可以添加 UITableView
UIScrollView
将内容大小设置为 UITableView
height。
And then you can add the UITableView
on UIScrollView
by setting it's content size as UITableView
height.
这篇关于使UITableView不可滚动并调整高度以容纳所有单元格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文