Search code examples
uisearchbaruisearchbardisplaycontrol

Setting UISearch in navigation bar in ios7


I'm having a search bar in my navigation bar using

[self.searchDisplayController setDisplaysSearchBarInNavigationBar:YES];

It displays a search results view when the search bar is tapped but there is no cancel button in the search results view.Can u please give me suggestion for doing it programmatically

I have to do it programmatically.

Plz anybody give me a hand.

Thankz in advance


Solution

  • You should be able to use:

    [self.searchDisplayController.searchBar setShowsCancelButton:YES animated:YES]
    

    I'm using something like this myself (implementing UISearchDisplayDelegate):

    - (void)searchDisplayControllerWillBeginSearch:(UISearchDisplayController *)controller {
      [controller.searchBar setShowsCancelButton:YES animated:YES];
    }