title: UISearchBar won't hide keyboard on resignFirstResponder when moving to another view controller
body: <p>I have a UISearchBar that behaves normally - the keyboard goes away if I hit "Search" or "Cancel".  </p>
  
  <p>However, when I push a new view controller on my navigation stack, if the keyboard is open, it won't close.  It stays there in the old view controller, and if I navigate back to it the keyboard is still shown.</p>
  
  <p>I'm stumped because my searchBarShouldEndEditing method is called as expected, and I do [activeSearchBar resignFirstResponder].  This works for "Search" or "Cancel", but not when it's triggered by the view disappearing.</p>
  
  <p>My delegate code:</p>
  
  <pre><code>#pragma mark Search bar delegate methods__________________________
  
  - (BOOL)searchBarShouldBeginEditing:(UISearchBar *)activeSearchBar
  {
      NSLog(@"searchBarShouldBeginEditing");
      [activeSearchBar setShowsCancelButton:TRUE animated:YES];
  
      if (!showSearchType)
          return TRUE;
  
      if([UIView respondsToSelector:@selector(animateWithDuration:animations:)]) {
          // iOS 4.0 and later
          [UIView animateWithDuration:0.3 animations:^ {
              searchTypeView.frame = CGRectMake(0, 44, 320, 69);
              searchTypeView.bounds = CGRectMake(0, 0, 320, 69);
              grayBg.alpha = 0.6;
          }];
      } else {
          // Before iOS 4.0
          searchTypeView.frame = CGRectMake(0, 44, 320, 69);
          searchTypeView.bounds = CGRectMake(0, 0, 320, 69);
          grayBg.alpha = 0.6;
      }
  
      self.frame = CGRectMake(0, 0, 320, 113);
  
      [self bringSubviewToFront:searchTypeView];
      [self bringSubviewToFront:activeSearchBar];
  
      return TRUE;
  }
  
  
  - (BOOL)searchBarShouldEndEditing:(UISearchBar *)activeSearchBar
  {
      NSLog(@"searchBarShouldEndEditing");
  
      if ([activeSearchBar isFirstResponder]) {
          NSLog(@"activeSearchBar isFirstResponder");
      }
      [activeSearchBar resignFirstResponder];
  
      [activeSearchBar setShowsCancelButton:FALSE animated:YES];
  
      if (!showSearchType)
          return TRUE;
  
      if([UIView respondsToSelector:@selector(animateWithDuration:animations:)]) {
          // iOS 4.0 and later
          [UIView animateWithDuration:0.3 animations:^ {
              searchTypeView.frame = CGRectMake(0, 9, 320, 69);
              searchTypeView.bounds = CGRectMake(0, 0, 320, 0);
              grayBg.alpha = 0;
          }];
      } else {
          // Before iOS 4.0
          searchTypeView.frame = CGRectMake(0, 9, 320, 69);
          searchTypeView.bounds = CGRectMake(0, 0, 320, 0);
          grayBg.alpha = 0;
      }
  
      self.frame = CGRectMake(0, 0, 320, 44);
  
      return TRUE;
  }
  
  - (void)searchBarTextDidEndEditing:(UISearchBar *)activeSearchBar {
      NSLog(@"searchBarTextDidEndEditing");
  
      if ([activeSearchBar isFirstResponder]) {
          NSLog(@"activeSearchBar isFirstResponder");
      }
  
      [activeSearchBar resignFirstResponder];
  
  }
  
  - (void)searchBarCancelButtonClicked:(UISearchBar *)activeSearchBar
  {
      NSLog(@"searchBarCancelButtonClicked");
  
      [activeSearchBar resignFirstResponder];
  }
  
  - (void)searchBarSearchButtonClicked:(UISearchBar *)activeSearchBar
  {
      NSLog(@"searchBarSearchButtonClicked");
  
      self.query = searchBar.text;
  
      [activeSearchBar resignFirstResponder];
  
      [searchView startSearch];
  }
  </code></pre>
  
  <p>This outputs:</p>
  
  <pre><code>2011-12-07 20:00:33.061 MyApp[55725:307] searchBarShouldEndEditing
  2011-12-07 20:00:33.063 MyApp[55725:307] activeSearchBar isFirstResponder
  2011-12-07 20:00:33.066 MyApp[55725:307] searchBarTextDidEndEditing
  </code></pre>
  
  <p>Thanks for any ideas!</p>