xcode UIScrollView 里面的 UICollectionView
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16224599/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
UICollectionView inside of UIScrollView
提问by Simon Edstr?m
I have a
我有一个
- UIScrollView
- Labels
- Labels
- UICollectionView
- 用户界面滚动视图
- 标签
- 标签
- 用户界面集合视图
I have disabled the UICollectionViews scrolling functionality, so I only want to scroll with the Scrollview. My problem is that I don't know how I can calculate the UICollectionViews height so I can update my UIScorllView. If it's many elements inside the UICollectionView, it's get clipped.
我已禁用 UICollectionViews 滚动功能,因此我只想使用 Scrollview 滚动。我的问题是我不知道如何计算 UICollectionViews 高度以便更新我的 UIScorllView。如果 UICollectionView 中有很多元素,它就会被剪掉。
I have created this little HTML example to show what I'm looking for http://jsfiddle.net/hDwPH/
我创建了这个小的 HTML 示例来展示我正在寻找的内容 http://jsfiddle.net/hDwPH/
Dummy code
采纳答案by Ben Coffman
So my suggestion would be to use a single UIScrollview. Create your own view (we'll call it A) with whatever you are trying to repeat in the Collection view and addSubview A to the UIScrollview over and over for however many times you want.
所以我的建议是使用单个 UIScrollview。创建您自己的视图(我们将其称为 A),使用您尝试在 Collection 视图中重复的任何内容,然后将Subview A 一遍又一遍地添加到 UIScrollview 中,无论您想要多少次。
Another way that just came to mind would be to use entirely a collectionview create two collectionviewcells, one that has your labels and you only display it for the first cell and the other collectionviewcell for all the others
刚刚想到的另一种方法是完全使用 collectionview 创建两个 collectionviewcells,一个有你的标签,你只为第一个单元格显示它,为所有其他单元格显示另一个 collectionviewcell