title: Strange UISearchBar cancel button behaviour in iphone (Working fine in Simulator)
body: <p>I am showing some Lists in UITableView. For sorting purpose i have used UISearchBar. I am getting some strange behaviors of Cancel button</p>
  
  <p>Steps to reproduce</p>
  
  <ol>
  <li>Search for something </li>
  <li>Notice that while you are searching, there is a 'Cancel' button that will get rid of the onscreen keyboard.</li>
  <li>Now tap into detail of one of the search results</li>
  <li>Then go back</li>
  <li>The search results are still there, and the search bar is there, but the 'Cancel' button is missing.</li>
  <li>So there is no way to remove the onscreen keyboard without closing the application and re-opening.</li>
  </ol>
  
  <p>But these scenario occurring only in iphone not in simulator. I am able to see Cancel button when i go back to first screen.</p>
  
  <p>I have used these delegates:</p>
  
  <pre><code>- (void)searchBarCancelButtonClicked:(UISearchBar *)searchBar
  {   
    searchBar.text = nil; 
    [searchBar resignFirstResponder];
    isSearch = NO;
  }
  
  - (BOOL)searchBarShouldEndEditing:(UISearchBar *)searchBar
  {  
    searchBar.showsScopeBar = NO;  
    [searchBar sizeToFit];  
    [searchBar setShowsCancelButton:NO animated:YES]; 
    return YES;   
  }  
  
  - (BOOL)searchBarShouldBeginEditing:(UISearchBar *)searchBar
  {  
    searchBar.showsScopeBar = YES;  
    [searchBar sizeToFit];  
    [searchBar setShowsCancelButton:YES animated:YES];  
    isSearch = YES;
    return YES;    
  }  
  </code></pre>
  
  <p>Please help</p>