How to use the gesture recognizer for iOS

In the workshop page, I've added a class and example to get swipe recognition in iOS using the native GestureRecognizers. It takes ofxGestureRecognizer as a starting point

Here are the instructions

1. put the ofxiOSSwipeRecognizer folder in your addons folder and either
- create an Xcode project with the projectGenerator with the addon checked.
- drag it to the addons folder of an existing project.

2. In testApp.h, create an instance of the swipe recogniser (you should create one instance per direction you want to detect).

ofxiOSSwipeRecognizer leftSwipeRecognizer; 

3. add a method to that will receive the swipe

void onSwipeLeft(ofxiOSSwipeEventArgs & args); 

4. in testApp.cpp call swipeRecognizer.setup on setup passing the direction of the swipe (if you don't pass any it'll use left, which is apple's default)


5. add a listener for the swipeRecognized event


ofAddListener(leftSwipeRecognizer.swipeRecognized, this, &testApp::onSwipeLeft);

6. implement the onSwipeLeft method and do cool things with it

void testApp::onSwipeLeft(ofxiOSSwipeEventArgs & args){ .... }


Difficulty: ●○○○○


Last updated: 7 years ago