I haven't been able to find a tutorial on how to properly setup a gesture recognizer for iOS. I need to detect swipe up & down, and the callbacks for them.
Any help, appreciated. Thanks.
UIPageViewController can handle swipes and view transitions.
Swipe right or left along the bottom edge of the screen to quickly switch between open apps. See Switch between open apps on iPhone.
You need two recognizers, one for swiping up, and the other for swiping down:
UISwipeGestureRecognizer* swipeUpGestureRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeUpFrom:)];
swipeUpGestureRecognizer.direction = UISwipeGestureRecognizerDirectionUp;
and for the handler:
- (void)handleSwipeUpFrom:(UIGestureRecognizer*)recognizer {
}
Finally, you add it to your view:
[view addGestureRecognizer:swipeUpGestureRecognizer];
The same for the other direction (just change all the Up
s to Down
s).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With