Created
August 13, 2015 20:13
-
-
Save antonio081014/0ad8b1a0aeba04f92393 to your computer and use it in GitHub Desktop.
A Simple Demo of Using UISwipeGestureRecognizer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)viewDidLoad | |
{ | |
[super viewDidLoad]; | |
UISwipeGestureRecognizer *leftGesture = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipe:)]; | |
leftGesture.direction = UISwipeGestureRecognizerDirectionDown; | |
[self.tableView addGestureRecognizer:leftGesture]; | |
UISwipeGestureRecognizer *rightGesture = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipe:)]; | |
rightGesture.direction = UISwipeGestureRecognizerDirectionUp; | |
[self.tableView addGestureRecognizer:rightGesture]; | |
} | |
- (void)swipe:(UISwipeGestureRecognizer *)gesture | |
{ | |
if (gesture.state == UIGestureRecognizerStateEnded) { | |
switch (gesture.direction) { | |
case UISwipeGestureRecognizerDirectionUp: | |
break; | |
case UISwipeGestureRecognizerDirectionDown: | |
break; | |
default: | |
break; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment