1
votes

I have a TableViewController and UISearchController that I attached in viewDidLoad to it.

- (void)viewDidLoad
{
    _searchController = [[UISearchController alloc] initWithSearchResultsController:nil];
    _searchController.searchResultsUpdater = self;
    _searchController.searchBar.delegate = self;
    [self.tableView.tableHeaderView addSubview:_searchController.searchBar];

}

While entering something into the search text field everything works, but if I tap on the results table, then the text field gets cleared and the Cancel button disappears. If I use the "Search" button from the keyboard instead, everything seems to be perfectly fine, until I tap on on the Table. Why is it that my SearchBar gets cleared when I tap on my TableView?

I'm using XCode 7.3 and iOS 9.

1

1 Answers

1
votes

Adding _searchController.dimsBackgroundDuringPresentation = NO; fixed the problem, if someone will ever run into this problem.