开发者

Strange UISearchBar cancel button behaviour in iphone (Working fine in Simulator)

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

  1. Search for something
  2. Notice that while you are searching, there is a 'Cancel' button that will get rid of the onscreen keyboard.
  3. Now tap into detail of one of the search results
  4. Then go back
  5. The search results are still there, and the search bar is there, but the 'Cancel' button is missing.
  6. 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 开发者_JAVA技巧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


Try this post.

I would suggest you use UISearchDisplayController - a helpful tutorial?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜