GestureRecognizer not working with UIScrollView in Objective-C?

Total Post:16

 1264  View(s)
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]
[self.scrollView addGestureRecognizer:doubleTap];
and this is the implementation:

//here I am doing some UIRelatedTasks
Can any one tell me how can I solve this issue?
  1. Post:214

    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
    doubleTap.numberOfTapsRequired = 2;
    [self.scrollView addGestureRecognizer: doubleTap];

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