iPhone 手势识别
- (void)viewDidLoad {
[super viewDidLoad];
UISwipeGestureRecognizer *recognizer = nil;
//
// 向右划动
//
recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeFrom:)];
[recognizer setDirection:(UISwipeGestureRecognizerDirectionRight)];
[self.view addGestureRecognizer:recognizer];
[recognizer release];
//
// 向左划动 www.zzzyk.com
//
recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeFrom:)];
[recognizer setDirection:(UISwipeGestureRecognizerDirectionLeft)];
[self.view addGestureRecognizer:recognizer];
[recognizer release];
}
- (void)handleSwipeFrom:(UISwipeGestureRecognizer *)recognizer {
if (recognizer.direction == UISwipeGestureRecognizerDirectionRight) {
// TODO:
}
else if (recognizer.direction == UISwipeGestureRecognizerDirectionLeft) {
// TODO:
}
}
摘自 wangsoko的专栏
补充:移动开发 , IOS ,