0

In my app I have a swipe gesture recogniser on my background scroller for the up direction but somehow it does not work. Here is my code below

It is in viewDidLoad

UISwipeGestureRecognizer *Swipe = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(SwipeRecognizer:)];
Swipe.direction = UISwipeGestureRecognizerDirectionUp;
[backgroundScroller addGestureRecognizer:Swipe];

and it is the SwipeRecognizer:

- (void) SwipeRecognizer:(UISwipeGestureRecognizer *)sender {
    if (sender.direction | UISwipeGestureRecognizerDirectionUp){
        NSLog(@" *** SWIPE UP ***");
    }
}

However I cant have any log. Am I missing something? Thanks.

EDIT: I found the problem. when I said scrolling is not enabled, I can recognise the gesture. But I need to to scrolling and gesture recognition simultaneously. isn't it possible?

death7eater
  • 1,094
  • 2
  • 14
  • 35

2 Answers2

0

Have u registered UIGestureRecognizerDelegate in .h file like this:

@interface yourViewController : UIViewController<UIGestureRecognizerDelegate>

Also

-(void)SwipeRecognizer:(UISwipeGestureRecognizer *)sender{
  if (sender.direction == UISwipeGestureRecognizerDirectionUp){
    NSLog(@" *** SWIPE UP ***");
  }
}
Paresh Navadiya
  • 38,095
  • 11
  • 81
  • 132
0

Try like this. If you don't get any NSLog(@" *** SwipeRecognizer ***") out put then i think you didnt tuch on SwipeRecognizer.

- (void) SwipeRecognizer:(UISwipeGestureRecognizer *)sender {
 NSLog(@" *** SwipeRecognizer ***");
if (sender.direction == UISwipeGestureRecognizerDirectionUp){
    NSLog(@" *** SWIPE UP ***");
}
}

I think it will be helpful to you.

Prasad G
  • 6,702
  • 7
  • 42
  • 65