获取 UICollectionView 中 Scroll 的总高度? [英] Get the total height of Scroll within UICollectionView?
本文介绍了获取 UICollectionView 中 Scroll 的总高度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个 UICollectionView
,我想在加载内容时调整它的大小(高度).这个想法是高度应该扩展,以便所有 UICollectionView 单元格都可见.我想知道是否可以获取内容"大小或滚动高度?
I have a UICollectionView
that I would like to resize (height) when the content is loaded. The idea is that the height should expand so that all UICollectionView Cells are visible. I was wondering if it was possible to get the "content" size or the scroll height?
谢谢
推荐答案
简单,集合视图是 UIScrollView
的子类,所以你可以读取它的 contentSize
属性.
Easy, a collection view is a subclass of UIScrollView
, so you can read its contentSize
property.
CGFloat h = self.collectionView.contentSize.height;
表格视图也是如此.
旁注:我什至做过一次 KVO,以便在内容大小发生变化时得到通知.
Sidenote: I even have done KVO on it once, to get notified when the content size changes.
这篇关于获取 UICollectionView 中 Scroll 的总高度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文