Ios – UICollectionView and ScrollView inside View with vertical scrolling

iosscrolluicollectionviewxcode

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

Best Answer

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
Related Topic