iOS Tap gesture state begin doesn't hit

UITapGestureRecognizer will never go in the UIGestureRecognizerStateBegan state. Only continuous gestures (such as a swipe or a pinch) will result for their recognizers going from UIGestureRecognizerStatePossible to UIGestureRecognizerStateBegan. Discrete gestures, such as a tap, put their recognizers directly into UIGestureRecognizerStateRecognized, i.e. for a single tap, right into UIGestureRecognizerStateEnded.

That said, maybe you're looking for a UILongPressGestureRecognizer, which is a continuous recognizer that will enter UIGestureRecognizerStateBegan, allowing you to discern beginning and end of touch?


It might be too late. But this will also help you, if you strictly want to use Gesture recognizer.

   UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc]
                                         initWithTarget:self 
                                         action:@selector(refresh:)];
    longPress.minimumPressDuration = 0.0;

 - (IBAction)refresh:(UILongPressGestureRecognizer *)sender {
     if(self.currentStatus == NODATA){
       if(sender.state == UIGestureRecognizerStateBegan){
         NSLog(@"Began!");
         [self.dashboardViewController.calendarContainer state:UIViewContainerStatusSELECTED];
       }
       if (sender.state == UIGestureRecognizerStateEnded){
         NSLog(@"%@", @"Ended");
        [self.dashboardViewController.calendarContainer state:UIViewContainerStatusNORMAL];
       } 
       [self setState:REFRESHING data:nil];
    }
   }

You can also use touchesBegan:withEvent: and touchesEnded:withEvent: methods.

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
    NSSet *t = [event touchesForView:_myView];
    if([t count] > 0) {
        // Do something 
    }
}

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
    NSSet *t = [event touchesForView:_myView];
    if([t count] > 0) {
        // Do something
    }
}