Open jinliyuelong opened 5 years ago
当自定义搜索建议的cell且searchTextDidChange中执行搜索时,搜索结果列表没有刷新。查看源代码为
- (void)setSearchSuggestions:(NSArray<NSString *> *)searchSuggestions { if ([self.dataSource respondsToSelector:@selector(searchSuggestionView:cellForRowAtIndexPath:)]) { // set searchSuggestion is nil when cell of suggestion view is custom. _searchSuggestions = nil; return; } _searchSuggestions = [searchSuggestions copy]; self.searchSuggestionVC.searchSuggestions = [searchSuggestions copy]; self.baseSearchTableView.hidden = !self.searchSuggestionHidden && [self.searchSuggestionVC.tableView numberOfRowsInSection:0]; self.searchSuggestionVC.view.hidden = self.searchSuggestionHidden || ![self.searchSuggestionVC.tableView numberOfRowsInSection:0]; }
通过源代码可知道,当有自定义cell时,就直接return了,也就不会执行的searchSuggestionVC.tablevew reload。所以我修改了一下,修改为当有自定义cell时,也会reload一下;
- (void)setSearchSuggestions:(NSArray<NSString *> *)searchSuggestions { if ([self.dataSource respondsToSelector:@selector(searchSuggestionView:cellForRowAtIndexPath:)]) { // set searchSuggestion is nil when cell of suggestion view is custom. [self.searchSuggestionVC.tableView reloadData]; _searchSuggestions = nil; return; } _searchSuggestions = [searchSuggestions copy]; self.searchSuggestionVC.searchSuggestions = [searchSuggestions copy]; self.baseSearchTableView.hidden = !self.searchSuggestionHidden && [self.searchSuggestionVC.tableView numberOfRowsInSection:0]; self.searchSuggestionVC.view.hidden = self.searchSuggestionHidden || ![self.searchSuggestionVC.tableView numberOfRowsInSection:0]; }
当自定义搜索建议的cell且searchTextDidChange中执行搜索时,搜索结果列表没有刷新。查看源代码为
通过源代码可知道,当有自定义cell时,就直接return了,也就不会执行的searchSuggestionVC.tablevew reload。所以我修改了一下,修改为当有自定义cell时,也会reload一下;