在Swift中获取表内容的高度 [英] Get Height of Table Contents in Swift
本文介绍了在Swift中获取表内容的高度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图获取表中所有内容的高度,以便更新其所在的容器.这将使容器和滚动视图中的其他视图一起滚动.
I'm trying to get the height of all of a table's contents so I can update the container it is in. This will allow the container and other views in the scroll view to scroll together.
推荐答案
Swift :
var tableViewHeight: CGFloat {
tableView.layoutIfNeeded()
return tableView.contentSize.height
}
Objective-C
- (CGFloat)tableViewHeight {
[tableView layoutIfNeeded];
return [tableView contentSize].height;
}
这篇关于在Swift中获取表内容的高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文