-1

I want to have two collection views that scrolls like this: the goal

I have achieved this but I then have the problem that when I scroll down the green collection view scrolls for alone and not the whole view: collection view with scroll

I then locked the scroll in the green collection view and put a scroll view around the whole screen. But when you scroll the collection view gets cut like this: collectionview locked

I have seen other apps like medium have two collection view that scrolls in two directions but I can not figure out have to achieve this. Medium home

To make the scroll view able to scroll have I done this to calculate the height of the two collectio views and then setting the heigt to the scrollview:

var size : CGSize
let height = firstView.frame.height + 
secondview.collectionViewLayout.collectionViewContentSize.height
size = CGSize(self.view.frame.width,height)
scrollview.contentSize = size

And my guess is that I might want to do the same for the green collection view but I have not got that to work.

Thanks!

Community
  • 1
  • 1
  • Possible duplicate of [Horizontal UITableView](https://stackoverflow.com/questions/2870680/horizontal-uitableview) – maxwell Apr 03 '18 at 12:47

1 Answers1

0

Take a UITableView (for vertical scrolling). Put a collection view (with horizontal scrolling) in the header of the table view. By doing this, you would have horizontally scrollable view and the problem of cutting of view would be fixed. Moreover, you will not have to take another view for vertical scrolling. You will achieve that with the cells of table view.

Design like Medium (or many other apps) are easily achievable this way. A table view (vertical scrolling), a collection view (horizontal scrolling) as table view's header, and rest everything would be managed by table view. Give it a try.

Pallav Trivedi
  • 316
  • 1
  • 15