I have a very special request. No tutorial or already asked questions worked for me due to not the same scenario. Its special because i want to enhance an existing app without reprogramming all of the code.
I want to programmatically add a UISearchbar. The Searchbar should be added to a UITableView which is programmatically added too.
This all takes place in a normal UIViewController.
My current approach displays the Searchbar but it does not search within my UITableView. Simply nothing happens.
What am I doing wrong?
myTableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStyleGrouped];
UISearchBar *searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0, 0, 320, 44)];
searchBar.delegate = self;
myTableView.tableHeaderView = searchBar;
UISearchDisplayController *searchController = [[UISearchDisplayController alloc] initWithSearchBar:searchBar contentsController:self];
searchController.searchResultsDataSource = self;
searchController.searchResultsDelegate = self;
searchController.delegate = self;
myTableView.dataSource = self;
myTableView.delegate = self;
[self.view addSubview:myTableView];