5
votes

How can I scroll entire window with UIScrollView on top to display a image gallery, and an UICollectionView to show another items? (See the mockup bellow)

I tried this structure but only the collection view scrolls and scrollview stays on the top.

  • View
    • UIScrollView
    • UICollectionView

What control should I use to group the scrollview and collectionview to have vertical scrolling on the entire window (and the collection view to grow with it contents)?

[Mockup] http://img835.imageshack.us/img835/3138/prototyperl.png

2
Did you find a solution for this ? - Kong Hantrakool
I followed the solution below - Cleyton T.
Thanks,Cleyton. I ended up using another method. One viewconroller which has view ->scrollview -> view & collectionview . The differences is in performance but my collection view has few cells.So it is not a big deal . My upper also has many buttons (profile page in Instagram) so if I put them all or in first header ,it might complicate things somehow. - Kong Hantrakool

2 Answers

2
votes

I would just use a UICollectionView and add the UIView as the header for the first section - and it would properly also be the simplest solution.

If you wrap the UICollectionView in the ScrollView and resizes the UICollectionView to fit content size you will most likely get poor performance, because all cells will be rendered when the view is shown(Not when cells are visible) - missing the point of reusable cells.

Override UICollectionViewDataSource delegate method:

-(UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath
1
votes

UIScrollView as the parent with the other two as children

  • UIScrollView
    • UIView
    • UICollectionView