Reputation: 7900
I have UISearchController
in my app and this is the code I'm using to create it:
-(void)setSearchBar {
self.resultsController = [[UITableViewController alloc] initWithStyle:UITableViewStylePlain];
[self.resultsController.tableView registerClass:UITableViewCell.self forCellReuseIdentifier:@"SearchTitleCell"];
self.resultsController.tableView.dataSource = self;
self.resultsController.tableView.delegate = self;
self.searchController = [[UISearchController alloc] initWithSearchResultsController:self.resultsController];
[self.searchController setSearchResultsUpdater:self];
[self.searchController setDelegate:self];
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"9.1")) {
self.searchController.obscuresBackgroundDuringPresentation = NO;
}
self.extendedLayoutIncludesOpaqueBars = YES;
self.navigationItem.searchController = self.searchController;
self.searchController.searchBar.delegate = self;
}
I noticed that in IOS 13 it's working fine, but in IOS 12 I can't see the searchbar
as shown in the photos:
Any idea what is the problem?
Upvotes: 1
Views: 168
Reputation: 1320
In iOS 12 the search bar is shown below the results controller.
To fix that you have to set self.definesPresentationContext = true
for the main controller in your code.
You can also do this on a storyboard.
Upvotes: 2