I have a parent UIScrollView
and a UICollectionView
inside that UIScrollView
.
I want that UICollectionView
scroll begins only when the parent UIScrollView
reaches end of its scrolling. Can any one please help me for the same.
Asked
Active
Viewed 1,841 times
3

ChintaN -Maddy- Ramani
- 5,156
- 1
- 27
- 48

Saraswati
- 1,516
- 1
- 14
- 21
-
1put one codition in scrollview delagates method and check the your current scroll is end of your first scroll then disable it and make child scroll enable – Himanshu Moradiya Jan 04 '17 at 10:35
-
you need off scrolling for collection view if Current contentOffSet of scrollview less than max off set of this scroll – Matloob Hasnain Jan 04 '17 at 10:36
-
Can you please show what all you may have tried in solving your problem? – Rikh Jan 04 '17 at 10:42
2 Answers
1
In viewDidLoad, Disable Collectionview scroll.
self.collectionView.scrollEnabled = NO;
Now, Use Delegate of scrollview to detect bottom of the scroll view and than enable CollectionView scroll.
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
float bottomEdge = scrollView.contentOffset.y + scrollView.frame.size.height;
if (bottomEdge >= scrollView.contentSize.height) {
self.collectionView.scrollEnabled = YES;
}
}
Hope it will work.

Chandan kumar
- 1,074
- 12
- 31
0
Initially set the child scrollView yourScrollView.scrollEnabled = NO;
also add tags to your scrollViews. 1 for parent and 2 for child preferably.
Get to know if you are at the bottom of the ScrollView using this code
-(void)scrollViewDidScroll: (UIScrollView*)scrollView
{
if(scrollView.tag==1)
{
float scrollViewHeight = scrollView.frame.size.height;
float scrollContentSizeHeight = scrollView.contentSize.height;
float scrollOffset = scrollView.contentOffset.y;
if (scrollOffset == 0)
{
// then we are at the top
}
else if (scrollOffset + scrollViewHeight == scrollContentSizeHeight)
{
//Handle Code to activate the child scrollView.
// then we are at the end
}
}
}
Hope this helps. Happy Coding.
References SO Post

Community
- 1
- 1

Md. Ibrahim Hassan
- 5,359
- 1
- 25
- 45