What I want to achieve: http://youtu.be/SUWxVtpc0JA
What I can achieve: http://youtu.be/b1xH6Xsvxcg
I’m trying to do the same vertical parallax scrolling effect that the Year Walk Companion app does when you change from text page to menu.
I’ve been able to do this effect on UIScrollViews
that only move horizontally, by using a UIPanGestureRecognizer
to move up and down, (imagine swiping between nested arrays). However when I have a UIScrollView
with the vertical scrolling it breaks.
When I scroll down the UIScrollView
it moves as you would expect, same if you move up. However the issues start when I want the UIPanGestureRecognizer
to come in and move the UIScrollView
itself vertically, not it’s content. To do this so far I have subclassed UIScrollView
to make a test on the function gestureRecognizerShouldBegin
:
-(BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer{
UIPanGestureRecognizer* pan = (UIPanGestureRecognizer*)gestureRecognizer;
CGPoint panGestureTranslation = [pan translationInView:self];
if (self.contentOffset.y == 0 && panGestureTranslation.y > 0 ) {
return NO;
}
return YES;
}
It returns NO
when my UIScrollView
is at the top, and allows my other UIPanGesture for the parallax scrolling between pages to start again.
My problem is, when my UIScrollView
is scrolling and reached the top, the function gestureRecognizerShouldBegin
will not be called and force me to release the touch before allowing the UIPanGestureRecognizer
to parallax scroll.
The question: How can I stop the handle of the touch by the UIScrollView
and let the UIPanGestureRecognizer
get the touch going up without release my finger from the screen? (like in the Year Walk Companion app).