I have two ways of searching for friends within my app. One of them is a snapchat similar interface where the added friends are shown and possibility of adding a friend is shown with a + sign. I tried adding a search bar somewhere within the area programmatically but got no results of nothing displaying. The code was implemented on my FriendsViewController that I am using and this is the current code I have:
-(void)initialiseSearchBar
{
self.searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 44)];
UITableViewController *searchResultsController = [[UITableViewController alloc] initWithStyle:UITableViewStylePlain];
searchResultsController.tableView.dataSource = self;
searchResultsController.tableView.delegate = self;
searchResultsController.tableView.backgroundColor = [UIColor colorWithWhite:0 alpha:0.7];
self.searchController = [[UISearchController alloc] initWithSearchResultsController:searchResultsController];
self.tableView.tableHeaderView = self.searchController.searchBar;
self.searchController.searchResultsUpdater = self;
[self.tableView setContentOffset:CGPointMake(0, 0)];
self.edgesForExtendedLayout = UIRectEdgeNone;
self.searchResults = [NSMutableArray array];
}
Any idea what I have done wrong or should fix? Also I am planning on releasing with iOS 7 compatibility and up all the way until 8.1, I have worries that the terms might be different or there is something depreciated that I do not know of.
You've allocated it but you haven't added it to the view itself unless it was made in storyboard (which you clearly state you didn't do) see my answer on another question... you have to add it as a subview somehow:
Adding A Search Bar