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.2cto.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的专栏
相关新闻>>
- 发表评论
-
- 最新评论 更多>>