I have a UICollectionView
inside a UIScrollView
.
My plan is, if the UICollectionView
reached the Top or Bottom the
outer ScrollView gets the scroll gestures. If the outer
ScrollView reached the Top or the Bottom, the CollectionView gets
the gestures.
How can I do it?
Okay, here is my Solution in some words:
- -Observe the contentOffset of both ScrollViews
- -Check when the inner scrollView reach the top or bottom
- -Disable the Scroll from the inner Scrollview
- -Enable the Scroll from the outer Scrollview
- -Check when the outer scrollView reach the top or bottom
- -Disable the Scroll from the outer Scrollview
- -Enable the Scroll from the inner Scrollview
very simple!
Observe the contentOffset like this:
[self.scrollView addObserver:self forKeyPath:@"contentOffset" options:NSKeyValueObservingOptionNew context:nil];
this methode get called:
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
if ([keyPath isEqualToString:@"contentOffset"]) {
} else {
}
}