Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UICollectionView and ScrollView inside View with vertical scrolling

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

like image 305
Cleyton T. Avatar asked Oct 22 '22 18:10

Cleyton T.


1 Answers

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
like image 80
Morten Holmgaard Avatar answered Oct 28 '22 15:10

Morten Holmgaard