I need to recognize swipes in all directions (Up/Down/Left/Right). Not simultaneously, but I need to recognize them.
I tried:
UISwipeGestureRecognizer *Swipe = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(SwipeRecognizer:)];
Swipe.direction = (UISwipeGestureRecognizerDirectionLeft |
UISwipeGestureRecognizerDirectionRight |
UISwipeGestureRecognizerDirectionDown |
UISwipeGestureRecognizerDirectionUp);
[self.view addGestureRecognizer:Swipe];
[Swipe release];
but nothing appeared on SwipeRecognizer
Here's the code for SwipeRecognizer:
- (void) SwipeRecognizer:(UISwipeGestureRecognizer *)sender {
if ( sender.direction == UISwipeGestureRecognizerDirectionLeft )
NSLog(@" *** SWIPE LEFT ***");
if ( sender.direction == UISwipeGestureRecognizerDirectionRight )
NSLog(@" *** SWIPE RIGHT ***");
if ( sender.direction == UISwipeGestureRecognizerDirectionDown )
NSLog(@" *** SWIPE DOWN ***");
if ( sender.direction == UISwipeGestureRecognizerDirectionUp )
NSLog(@" *** SWIPE UP ***");
}
How can I do this? How can assign to my Swipe object all different directions?
UISwipeGestureRecognizer *SwipeLeft; UISwipeGestureRecognizer *SwipeUp; [...]
? And assign to view like[self.view addGestureRecognizer:SwipeLeft]; [self.view addGestureRecognizer:SwipeUp]; [...]
??? – Menander