title: Dismiss SVProgressHUD with Tap Gesture
body: <p>I need to add a UITapGestureRecognizer to the <a href="https://github.com/SVProgressHUD/SVProgressHUD" rel="nofollow">SVProgressHUD</a>. The SVProgressHUD already has the ability to dismiss using <code>-(void) dismiss;</code>. The code for this will dismiss the animation based on seconds. </p>
  
  <pre><code>- (void)dismiss {
  for (UIGestureRecognizer *gesture in [[[self class] sharedView] gestureRecognizers]) {
      [[[self class] sharedView] removeGestureRecognizer:gesture];
  }
  
  NSDictionary *userInfo = [self notificationUserInfo];
  [[NSNotificationCenter defaultCenter] postNotificationName:SVProgressHUDWillDisappearNotification
                                                      object:nil
                                                    userInfo:userInfo];
  
  self.activityCount = 0;
  [UIView animateWithDuration:0.15
                        delay:0
                      options:UIViewAnimationCurveEaseIn | UIViewAnimationOptionAllowUserInteraction
                   animations:^{
                       self.hudView.transform = CGAffineTransformScale(self.hudView.transform, 0.8, 0.8);
                       if(self.isClear) // handle iOS 7 UIToolbar not answer well to hierarchy opacity change
                           self.hudView.alpha = 0;
                       else
                           self.alpha = 0;
                   }
                   completion:^(BOOL finished){
                       if(self.alpha == 0 || self.hudView.alpha == 0) {
                           self.alpha = 0;
                           self.hudView.alpha = 0;
  
                           [[NSNotificationCenter defaultCenter] removeObserver:self];
                           [self cancelRingLayerAnimation];
                           [self addTapGestureToDismiss];
                           [_hudView removeFromSuperview];
                           _hudView = nil;
  
                           [_overlayView removeFromSuperview];
                           _overlayView = nil;
  
                           [_indefiniteAnimatedView removeFromSuperview];
                           _indefiniteAnimatedView = nil;
  
  
                           UIAccessibilityPostNotification(UIAccessibilityScreenChangedNotification, nil);
  
                           [[NSNotificationCenter defaultCenter] postNotificationName:SVProgressHUDDidDisappearNotification
                                                                               object:nil
                                                                             userInfo:userInfo];
  
                           // Tell the rootViewController to update the StatusBar appearance
                           UIViewController *rootController = [[UIApplication sharedApplication] keyWindow].rootViewController;
                           if ([rootController respondsToSelector:@selector(setNeedsStatusBarAppearanceUpdate)]) {
                               [rootController setNeedsStatusBarAppearanceUpdate];
                           }
                           // uncomment to make sure UIWindow is gone from app.windows
                           //NSLog(@"%@", [UIApplication sharedApplication].windows);
                           //NSLog(@"keyWindow = %@", [UIApplication sharedApplication].keyWindow);
                       }
                   }];
  </code></pre>
  
  <p>}</p>
  
  <p>My thought process is to add the tapGesture code to the dismiss method. This is what I have written so far. </p>
  
  <pre><code>- (void)addTapGestureToDismiss {
  
  // Creation and initializer of the tap gesture
  UITapGestureRecognizer *tapRecognizer = [[UITapGestureRecognizer alloc]
                                           initWithTarget:self action:@selector(dismiss)];
  
  // Specify that the gesture must be a single tap
  tapRecognizer.numberOfTapsRequired = 1;
  
  // Add the tap gesture recognizer to the view
  [[[self class] sharedView] addGestureRecognizer:tapRecognizer];
  </code></pre>
  
  <p>}</p>
  
  <p>As you can see I'm just initializing the tapGesture. I've run into the issue of placing it in a few places and causing the app to only have one single tap. I've pretty much confused myself in the process. Should I</p>
  
  <ul>
  <li>add this gesture to the view?</li>
  <li>add this gesture to dismiss?</li>
  </ul>