We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
自定义搜索建议的 cell,选中进入后返回导致搜索建议消失
1,在选中建议时会设置 searchBar.text 为 textLabel.text 自定义cell 不一定设置cell默认textLabel #pragma mark - UITableViewDelegate
(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath]; [tableView deselectRowAtIndexPath:indexPath animated:YES]; self.searchBar.text = cell.textLabel.text;
if ([self.delegate respondsToSelector:@selector(searchViewController:didSelectSearchHistoryAtIndex:searchText:)]) { [self.delegate searchViewController:self didSelectSearchHistoryAtIndex:indexPath.row searchText:cell.textLabel.text]; [self saveSearchCacheAndRefreshView]; } else { [self searchBarSearchButtonClicked:self.searchBar]; } }
2,在返回刷新数据的时候会根据 !self.searchBar.text.lengt 来决定是否隐藏 searchSuggestionView,这个时候 searchBar.text 被设置为空了,,,,
The text was updated successfully, but these errors were encountered:
No branches or pull requests
问题描述
自定义搜索建议的 cell,选中进入后返回导致搜索建议消失
原因
1,在选中建议时会设置 searchBar.text 为 textLabel.text 自定义cell 不一定设置cell默认textLabel
#pragma mark - UITableViewDelegate
(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
[tableView deselectRowAtIndexPath:indexPath animated:YES];
self.searchBar.text = cell.textLabel.text;
if ([self.delegate respondsToSelector:@selector(searchViewController:didSelectSearchHistoryAtIndex:searchText:)]) {
[self.delegate searchViewController:self didSelectSearchHistoryAtIndex:indexPath.row searchText:cell.textLabel.text];
[self saveSearchCacheAndRefreshView];
} else {
[self searchBarSearchButtonClicked:self.searchBar];
}
}
2,在返回刷新数据的时候会根据 !self.searchBar.text.lengt 来决定是否隐藏 searchSuggestionView,这个时候 searchBar.text 被设置为空了,,,,
{
if ([self.dataSource respondsToSelector:@selector(searchSuggestionView:numberOfRowsInSection:)]) {
NSInteger numberOfRow = [self.dataSource searchSuggestionView:searchSuggestionView numberOfRowsInSection:section];
searchSuggestionView.hidden = self.searchSuggestionHidden || !self.searchBar.text.length || 0 == numberOfRow;
self.baseSearchTableView.hidden = !searchSuggestionView.hidden;
return numberOfRow;
}
return self.searchSuggestions.count;
}
The text was updated successfully, but these errors were encountered: