title: How to recognise a tap gesture outside of a modal dialog when dialog is open
body: <p>All I want to know is how to I recognise when a user taps outside of the modal dialog. 
  I have tried this but it is not being called when the user taps outside.</p>
  
  <p>Here is my viewDidLoad method which resides in the ModalDialogViewController.m file
       UITapGestureRecognizer *recognizer;</p>
  
  <pre><code>        if(![self.view.window.gestureRecognizers containsObject:recognizer])
          {
              recognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTapBehind:)];
              //[recognizer setDelegate:self];
              [recognizer setNumberOfTapsRequired:1];
              recognizer.cancelsTouchesInView = NO; //So the user can still interact with controls in the modal view
              [self.view.window addGestureRecognizer:recognizer];
  
          }
  </code></pre>
  
  <p>This is not opening the handleTapBehind method.</p>
  
  <p>I have made the modal view controller a protocol of UIGestureRecognition. </p>