In my iPhone app, I require to recognize the swipe gesture made by the user on the view.
I want the swipe gestures to be recognized and perform a function on swipe.
I need that the view should horizontally slide and show another view as a user makes a swipe gesture.
What needs to be done?
How do I recognize it?
Swiping in touch is the act of quickly moving your finger across the touch surface in a certain direction.
A swipe gesture occurs when the user moves one or more fingers across the screen in a specific horizontal or vertical direction. Use the UISwipeGestureRecognizer class to detect swipe gestures. You can attach a gesture recognizer in one of these ways: Programmatically.
Swipe right or left along the bottom edge of the screen to quickly switch between open apps. See Switch between open apps on iPhone.
If You know how it works, but still need a quick example, here it is! (it will become handy at least for me, when I will need copy-paste example, without trying remembering it)
UISwipeGestureRecognizer *mSwipeUpRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(doSomething)]; [mSwipeUpRecognizer setDirection:(UISwipeGestureRecognizerDirectionUp | UISwipeGestureRecognizerDirectionDown | UISwipeGestureRecognizerDirectionLeft | UISwipeGestureRecognizerDirectionRight)]; [[self view] addGestureRecognizer:mSwipeUpRecognizer];
and in .h file add:
<UIGestureRecognizerDelegate>
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