UITapGestureReconizer and Sashimi views

You will often need to add gesture recognizer on views where you have Sashimi views and this can interfere with the "click" detection mechanism of the Appsfire SDK. According to what you want to achieve, there are two cases to consider in order to overcome those problems:

  1. If you want to detect a tap on a Sashimi with a UITapGestureRecognizer and you do not want to interfere with the "click" detection mechanism of the Sashimi, you need to set the cancelsTouchesInView property of the UITapGestureRecognizer to NO.

    UITapGestureRecognizer *tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(didTapOnSashimiView:)];
    tapGestureRecognizer.cancelsTouchesInView = NO;
    [view addGestureRecognizer:tapGestureRecognizer];
    

    This will guarantee you to simultaneously detect a tap with your UITapGestureRecognizer and let the Sashimi handle the "click".

  2. If you have a Sashimi embedded in a UIView where you have a UITapGestureRecognizer and you want to disable taps on this Sashimi to let it handle the "click". In order to do so you will need to implement the gestureRecognizer:shouldReceiveTouch: method of UIGestureRecognizerDelegate and exclude the Sashimi view by returning NO at the right time.

    • Add the UIGestureRecognizerDelegate delegate to your class:

      @interface AFMyView : UIView <UIGestureRecognizerDelegate>  
      
    • Set the delegate of your gesture recognizer:

      tapGestureRecognizer.delegate = self;
      
    • Implement the gestureRecognizer:shouldReceiveTouch: method:

      - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch {
          if ([touch.view isKindOfClass:AFAdSDKSashimiView.class]) {
              return NO;
          }
      
          return YES;
      }