Swipe Gestures in Cocoa Touch

To use swipe gestures on the iOS SDK, you can use the following code to register the listener:

Swipe gestures in Objective-C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
UISwipeGestureRecognizer *swipeRight = [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(swipeRightAction:)];

swipeRight.direction = UISwipeGestureRecognizerDirectionRight;

swipeRight.delegate = self;

[self.view addGestureRecognizer:swipeRight];


UISwipeGestureRecognizer *swipeLeft = [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(swipeLeftAction:)];

swipeLeft.direction = UISwipeGestureRecognizerDirectionLeft;

swipeLeft.delegate = self;

[self.view addGestureRecognizer:swipeLeft];