1
votes

I've been trying to replicate this effect for a couple days which was inspired by Tumblr.

I've previously asked questions on here with different approaches of the same problem but to no avail. I'm just curious as to how the engineers at Tumblr created a horizontal collection view, with two vertical collection views, and is able to scroll down without affecting the view above (without resetting the position of the view when you scroll vertically in a different tab).

Header Views

I tried this, but the header view was isolated and I had to scroll to the right to see the collectionView cells. This did not work.

Changing the topLayoutConstraint constant of my UIView (not cv header) with respect to the contentOffSet of the vertical collectionView.

This almost got the effect I wanted, except that when I scrolled horizontally, there was a huge gap between my collection view and if I scrolled in that new tab, the UIView would appear again because, again, topLayoutConstraint gets scrolled up depending on the contentOffSet of my vertical collectionView contentOffset.

Changing the position of the UICollectionView frame, and scrolling the super view up simultaneously with NSNotificationCenter.

Alas, this method did the same as method #2, except that the vertical collection view cells scrolled faster than the super view.

I ran out of options to make this work so I will show you in detail what's attempted to be replicated (also note the scroll bar on the right):

enter image description here

Note when I scroll down the first tab. I switch, and then scroll down further. Originally, as I've said, there would be a gap between the second main CV, and when I scrolled, the view would reposition as if were scrolling up again. On here, the view on top keeps going up. So I'm curious as to what method Tumblr engineers used to do this. UICollectionView inside UIScrollView? Other suggestions?

1

1 Answers

0
votes

I believe there is no UICollectionView involved. It looks like UIPageViewController and each its page is a UITableView. Perhaps the UIPageViewController sits in a UITableView as well - the header also moves up when you scroll. This main table has only one cell (and a header) which is occupied by the UIPageViewController. Hope it helps.