I have two view controllers. View controller A has a UIScrollView
and presents view controller B. The presentation is interactive and controlled by the scrollView.contentOffset
.
I want to integrate an interactive dismiss transition: When panning up, ViewController B should be dismissed interactively. The interactive dismiss transition should also control the ViewController A scrollView.
My first attempt was using a UIPanGestureRecognizer
and setting the scrollView.contentOffset
according to the panned distance. This works, however when the pan gesture is ended, the scrollView offset has to be animated to the end position. Using -[UIScrollView setContentOffset:animated:
is not a good solution since it uses a linear animation, doesn't take the current pan velocity into account and doesn't decelerate nicely.
So I thought it should be possible to feed the touch events from my pan gesture recognizer into the scroll view. This should give us all the nice scroll view animation behavior.
I tried overriding the -touchesBegan/Moved/Ended/Cancelled withEvent:
methods in my UIPanGestureRecognizer
subclass like this:
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
[scrollView touchesBegan:touches withEvent:event];
[scrollView.panGestureRecognizer touchesBegan:touches withEvent:event];
[super touchesBegan:touches withEvent:event];
}
But apparently something is blocking the scroll view from entering tracking
mode. (It does go to dragging = YES
but that's about it.) I verified the scrollView is userInteractionEnabled
, not hidden and added to the view hierarchy.
So how can I forward my touch events to UIScrollView
?
Aucun commentaire:
Enregistrer un commentaire