2

I set my searchBar in the navigationBar. When activated it animates and the cancel button appears. I'm trying to stop animation and prevent cancel button from appearing. My story board is a tableviewController set in a navigationController.

self.searchController = [[UISearchController alloc]initWithSearchResultsController:nil];
self.searchController.searchResultsUpdater = self;
self.searchController.dimsBackgroundDuringPresentation = NO;
self.searchController.hidesNavigationBarDuringPresentation = NO;

self.searchController.searchBar.frame = CGRectMake(self.searchController.searchBar.frame.origin.x, self.searchController.searchBar.frame.origin.y, self.searchController.searchBar.frame.size.width, 44.0);

self.navigationItem.titleView = self.searchController.searchBar;
[self.searchController.searchBar setShowsCancelButton:NO animated:NO];
Ryasoh
  • 173
  • 1
  • 1
  • 10

1 Answers1

0

Try [self.searchController.searchBar showsCancelButton:NO].

Larry Borsato
  • 394
  • 3
  • 5
  • no luck, i'm getting "no visible @interface for 'UISearchBar' declares the selector 'showCancelButton'. – Ryasoh Dec 12 '14 at 00:09
  • My mistake. It is a property so it should be `[self.searchController.searchBar setShowsCancelButton:NO]` or `self.searchController.searchBar.showsCancelButton = NO;`. – Larry Borsato Dec 12 '14 at 01:00