2

Here's my architecture.

I have a UIScrollView with some UIView's added in. At the end on my scrollview i have a UICollectionView (embedded in my scrollview) in which i loads many data. I had to use a UICollectionView in order to reuse the multiple views displayed.

What i want is keep a smooth scroll when the user scrolls to the bottom of the parent scrollview and continue scrolling in the UICollectionView.

What i've made now is set the size of my UICollectionView equal to my UIScrollView Size and i've disabled bounces on both.

But i can't have a smooth scroll. When i reach the end of my UIScrollView, the scrollview's stop and then i have to re scroll on my UICollectionView

Not sure if it's really clear.

Jagat Dave
  • 1,643
  • 3
  • 23
  • 30
Pwyll28
  • 117
  • 11

1 Answers1

2

You should not normally "pass scroll" between elements. What you need to make sure is that the UICollectionView's frameSize is equal to its contentSize, meaning its frameSize expands as much as its contents so that all of its content is visible without having to scroll. Then your UIScrollView will handle the scroll and show the contents of your UIViewController by scrolling just itself.

dorian
  • 847
  • 5
  • 11
  • By doing this i come really fast to memory warning because none of the UICollectionViewCell's are reused – Pwyll28 Feb 17 '16 at 14:01
  • Here it shows how to properly resize a UICollectionView so that it fully displays its contents: http://stackoverflow.com/questions/20792299/uicollectionview-autosize-height/20829728#20829728 – dorian Feb 17 '16 at 14:04
  • I've already implemented a similar solution, but by doing this, i can't reuse all the cells displayed i my collection view – Pwyll28 Feb 17 '16 at 14:18
  • this has nothing to do with reuse tho. collectionView should handle the reuse as some cells goes into the viewPort and some goes out. This approach is pretty common I would say. – dorian Feb 17 '16 at 14:21
  • if you update the frame of your collection view basing on the contentSize. How would you have a reuse ? There's has much cells has it need to fill the contentSize. So no reuse. Let's say a cell size 50px in height and my UICollectionView's contentSize is 4000. I'll have 80 cells instantiated at the same time. That's not a good solution – Pwyll28 Feb 17 '16 at 14:25
  • actually you are probably right about the reuse now that I tried myself. I never had to deal with 1000s of cells so never had to think about it... Then you might have to rethink your design of having 2 scrollViews inside each other or come up with a custom scrolling (probably paging) solution within your collectionView along with the solution I suggested. – dorian Feb 17 '16 at 14:39