title: Call a function on a touch outside of the active UITextField
body: <p>How to call a custom function when the user touches outside of the UITextField that has keyboard focus? </p>
  
  <p>My goal is to call a function for textfield validation. </p>
  
  <p>I tried this:</p>
  
  <pre><code>// Dismiss Keyboard
  
  - (void)touchesEnded: (NSSet *)touches withEvent: (UIEvent *)event {
      for (UIView* view in self.view.subviews) {
          if ([view isKindOfClass:[UITextField class]]) 
          {
              [view resignFirstResponder];
              [self validationForNoOfPassengers];
          }
  
      }
  }
  </code></pre>
  
  <p><code>validationForNoOfPassengers</code> is my method to check for validation. The problem here is that when I tap on other UI controls it does not call the above method. Above method is called only when touched outside on the screen (but not on UIcontrols). Any guidance?</p>