title: How to prevent a UIView from momentarily disappearing upon a tap of the clear button in a UITextField?
body: <p>I'm running into an issue I cannot figure out how to resolve. I have a <code>UITextField</code> that allows a user to enter text to search.</p>
  
  <p>Initially the <code>UIView</code> is hidden.</p>
  
  <p>Below the <code>UITextField</code> is a <code>UIView</code> that gets triggered (hidden = false) when the user taps inside the <code>UITextField</code>.</p>
  
  <pre><code>func textFieldShouldBeginEditing(textField: UITextField) -&gt; Bool
  {
      inSearchModeView.hidden = false
      return true
  }
  </code></pre>
  
  <p>Below the <code>UITextField</code> is also a <code>UITableView</code> that contains the results of the search. I have it set up where if the user taps anywhere outside the <code>UITextField</code>, the keyboard dismisses. However, to ensure that I'm able to select the contents of the <code>UITableView</code> if there are any returnable results, I've set this up:</p>
  
  <pre><code>func gestureRecognizer(gestureRecognizer: UIGestureRecognizer, shouldReceiveTouch touch: UITouch) -&gt; Bool
  {
      if touch.view.self == videosTableView.self
      {
          return false
      }
  
      print("test")
      self.inSearchModeView.hidden = true
  
      return true
  }
  </code></pre>
  
  <p>I would like to have the <code>inSearchModeView</code> remain visible when the Clear button is tapped.</p>
  
  <p>The problem is, if I type a text, then hit the Clear button, there were be 1/2 a second moment where the <code>inSearchModeView</code> disappears, then reappears again. Or, if I hold the Clear button, I see the <code>inSearchModeView</code> disappears, and upon release of the Clear button, it reappears and remain visible again.</p>
  
  <p>I noticed that with the print statement, I see <code>gestureRecognizer</code> is called when I tap the Clear button, even though it's within the <code>UITextField</code>.</p>
  
  <p>How can this be fixed to where my <code>inSearchModeView</code> remains visible unless I tap outside the <code>UITextField</code>?</p>
  
  <p>Here's my tap gesture code:</p>
  
  <pre><code>viewDidLoad
  { 
      let tap: UITapGestureRecognizer = UITapGestureRecognizer(target: self,     
      action: "dismissKeyboard")
          view.addGestureRecognizer(tap)
  }
  
  func dismissKeyboard()
  {
      // Causes the view (or one of its embedded text fields) to resign the first responder status.
      view.endEditing(true)
  }
  </code></pre>
  
  <p>Thanks</p>