- (void)handleSwipe:(UISwipeGestureRecognizer *)gesture {
UISwipeGestureRecognizerDirection direction = gesture.direction;
switch (direction) {
case UISwipeGestureRecognizerDirectionLeft:
break;
case UISwipeGestureRecognizerDirectionDown:
break;
case UISwipeGestureRecognizerDirectionRight:
break;
case UISwipeGestureRecognizerDirectionUp:
break;
default:
break;
}
}
- (void)viewDidLoad
{
//建立滑动手势
//设置滑动方向,下面以此类推
UISwipeGestureRecognizer *recognizer;
//向右滑动
recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeFrom:)];
[recognizer setDirection:(UISwipeGestureRecognizerDirectionRight)];
[[self view] addGestureRecognizer:recognizer];
[recognizer release];
//向左滑动
recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeFrom:)];
[recognizer setDirection:(UISwipeGestureRecognizerDirectionLeft)];
[[self view] addGestureRecognizer:recognizer];
[recognizer release];
//向上滑动
recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeFrom:)];
[recognizer setDirection:(UISwipeGestureRecognizerDirectionUp)];
[[self view] addGestureRecognizer:recognizer];
[recognizer release];
//向下滑动
recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipe:)];
[recognizer setDirection:(UISwipeGestureRecognizerDirectionDown)];
[[self view] addGestureRecognizer:recognizer];
[recognizer release];
}