Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can UITableView scroll with UICollectionView inside it?

I have the structures below...

enter image description here

I wrap two of collection views into tableview

One is in tableview header(Collection1), another is in tableview 1st row(Collection2).

All the functions are good (Both collection view).

just...

When I scroll up in Collection2, Collection1 will Not scroll up together, because I'm only scrolling the collectionViews not the tableview.

It only scroll together when I scroll in Collection1.

Is it possible to make the header view scroll with user just like app store's index carousel header?

Or I just went to the wrong place, I should use other ways to approach.

like image 456
S. Will Avatar asked Apr 14 '16 10:04

S. Will


1 Answers

Solution

  • When you keep CollectionView1 as a TableViewHeader, CollectionView1 will always on the top of TableView after it reaches top. If you want Collection1 and Collection2 scroll up together, you need to keep CollectionView1 in a cell, not a header.

  • Make sure CollectionView2 content height smaller or equal to TableViewCell's height. As I checked on App Store, they always make SubCollectionView content height equal to TableViewCell's height (If they use TableView).

Result

For more detail, you can take a look at my sample project

https://github.com/trungducc/stackoverflow/tree/app-store-header

like image 185
trungduc Avatar answered Sep 21 '22 07:09

trungduc