I got ViewController and UITableViewController
in it. In top of my VC I got Search bar. I need to connect Search bar with my tableView.
@interface MessageViewController : UIViewController <UITableViewDataSource, UITableViewDelegate, UISearchBarDelegate, UISearchDisplayDelegate>
//.m
self.searchDisplayController.searchBar.delegate = self;
self.searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0, 0, 270, kRowHeight)];
self.searchBar.delegate = self;
self.searchBar.backgroundColor = [UIColor colorWithWhite:0.9 alpha:0.7];
self.searchBar.barStyle = UISearchBarStyleDefault;
[self.view addSubview:self.searchBar];
#pragma mark - UISearchDisplayController Delegate Methods
- (BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString
{
[self doSearch];
return YES;
}
Why I not get updated tableView
?
After performing the search try to invoke [self.tableView reloadData];
, at the bottom of your doSearch
method to reload the content of your tableView
.