I am showing some Lists in UITableView. For sorting purpose i have used UISearchBar. I am getting some strange behaviors of Cancel button
Steps to reproduce
- Search for something
- Notice that while you are searching, there is a 'Cancel' button that will get rid of the onscreen keyboard.
- Now tap into detail of one of the search results
- Then go back
- The search results are still there, and the search bar is there, but the 'Cancel' button is missing.
- So there is no way to remove the onscreen keyboard without closing the application and re-opening.
But these scenario occurring only in iphone not in simulator. I am able to see Cancel button when i go back to first screen.
I have used these delegates:
- (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;
}
Please help