Я создал searchBar программно и добавил его в представление плитки панели навигации. Это мой код:
UISearchController *searchController = [[UISearchController alloc] initWithSearchResultsController:self];
searchController.dimsBackgroundDuringPresentation = YES;
// Use the current view controller to update the search results.
searchController.searchResultsUpdater = self;
//Setting Style
searchController.searchBar.barStyle = UIBarStyleBlack;
searchController.searchBar.barTintColor = [UIColor colorWithRed:49.0/255.0 green:49.0/255.0 blue:61.0/255.0 alpha:1.0];
searchController.searchBar.backgroundImage = [UIImage imageNamed:@"BG"];
searchController.searchBar.placeholder = @"Search Artists, Songs, Albums etc.";
searchController.searchBar.keyboardAppearance = UIKeyboardAppearanceDark;
self.definesPresentationContext = YES;
self.navigationItem.titleView = searchController.searchBar;
searchController.delegate = self;
searchController.searchBar.delegate = self;
[searchResultsTableView reloadData];
-(BOOL)searchBarShouldBeginEditing:(UISearchBar *)searchBar{
NSLog(@"Halp.jpg");
return YES;
}
Этот вышеуказанный метод вместе со всеми другими методами не вызывается. Мой заголовок выглядит так:
<UISearchResultsUpdating, UITableViewDelegate, UISearchControllerDelegate, UISearchBarDelegate, UITableViewDataSource>