GESTURERECOGNIZER NOT WORKING WITH UISCROLLVIEW IN OBJECTIVE-C?

Jessica James

Total Post:16

Points:114
Posted by  Jessica James
 775  View(s)
Ratings:
Rate this:
I have created an app using UIScrollView and I also added a gesture recognizer but calling method in gesture recognizer is not working.
this is the code:
UITapGestureRecognizer *doubleTap = [[UITapGestureRecognizer alloc]
initWithTarget:self
action:@selector(doubbleTapHandler:)];
[self.scrollView addGestureRecognizer:doubleTap];
and this is the implementation:

-(void)doubleTapHandler:(UITapGestureRecognizer*)recognizer
{
//here I am doing some UIRelatedTasks
}
Can any one tell me how can I solve this issue?
  1. Tarun Kumar

    Post:214

    Points:1642
    Re: GestureRecognizer not working with UIScrollView in Objective-C?

    According to the code you are provided above, you are created tap gesture recognizer and add it to the scrollview. All the thing is correct but tell me one thing how your scrollview will find that double tap is happening on it.
    So add this line of code, this scrollview will count the number of taps if 2 tap will happened on it then it will coll the selector method doubleTapHandler:
    doubleTap .numberOfTapsRequired=2;
    Here is your complete code:

    UITapGestureRecognizer *doubleTap = [[UITapGestureRecognizer alloc]
    initWithTarget: self
    action:@selector(doubbleTapHandler:)];
    doubleTap.numberOfTapsRequired = 2;
    [self.scrollView addGestureRecognizer: doubleTap];

      Modified On Feb-22-2016 05:41:37 AM

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!