Reloading UITableView behind UISearchDisplayController

前端 未结 9 2090
南旧
南旧 2021-02-07 11:26

I\'ve run into this really strange phenomenon that I can\'t quite figure out. I have a UITableViewController that manages a UITableView. Pretty simple. I also have a UISearch

9条回答
  •  清酒与你
    2021-02-07 11:50

    Hopefully you've figured this out by now, but just in case someone stumbles across this question: this is probably happening because your UITableViewController is the data source/delegate for the search table as well as your main table. That is, presumably, you have the same UITableViewDelegate/DataSource methods executing for both table views, and you're returning the same section header for both tables. Make sure you're handling your search results table separately:

    - (NSString *)tableView:(UITableView *)aTableView titleForHeaderInSection:(NSInteger)section {
        if (aTableView == [[self searchDisplayController] searchResultsTableView]) {
            return nil;
        }
        // Return a title appropriate for self.tableView here
    }
    

提交回复
热议问题