Skip to content
New issue

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

delete the sync code to solve the quick delete issue in searchbar and reduce logic complexity #98

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 1 addition & 12 deletions PYSearch/PYSearchViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -1035,18 +1035,7 @@ - (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar

- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText
{
if (PYSearchResultShowModeEmbed == self.searchResultShowMode && self.showSearchResultWhenSearchTextChanged) {
[self handleSearchResultShow];
self.searchResultController.view.hidden = 0 == searchText.length;
} else if (self.searchResultController) {
self.searchResultController.view.hidden = YES;
}
self.baseSearchTableView.hidden = searchText.length && !self.searchSuggestionHidden && [self.searchSuggestionVC.tableView numberOfRowsInSection:0];
self.searchSuggestionVC.view.hidden = self.searchSuggestionHidden || !searchText.length || ![self.searchSuggestionVC.tableView numberOfRowsInSection:0];
if (self.searchSuggestionVC.view.hidden) {
self.searchSuggestions = nil;
}
[self.view bringSubviewToFront:self.searchSuggestionVC.view];

if ([self.delegate respondsToSelector:@selector(searchViewController:searchTextDidChange:searchText:)]) {
[self.delegate searchViewController:self searchTextDidChange:searchBar searchText:searchText];
}
Expand Down
20 changes: 11 additions & 9 deletions PYSearchExample/PYSearchExample/PYSearchExampleController.m
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,17 @@ - (void)searchViewController:(PYSearchViewController *)searchViewController sear
{
if (searchText.length) {
// Simulate a send request to get a search suggestions
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.25 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
NSMutableArray *searchSuggestionsM = [NSMutableArray array];
for (int i = 0; i < arc4random_uniform(5) + 10; i++) {
NSString *searchSuggestion = [NSString stringWithFormat:@"Search suggestion %d", i];
[searchSuggestionsM addObject:searchSuggestion];
}
// Refresh and display the search suggustions
searchViewController.searchSuggestions = searchSuggestionsM;
});

NSMutableArray *searchSuggestionsM = [NSMutableArray array];
for (int i = 0; i < arc4random_uniform(5) + 10; i++) {
NSString *searchSuggestion = [NSString stringWithFormat:@"Search suggestion %d", i];
[searchSuggestionsM addObject:searchSuggestion];
}
// Refresh and display the search suggustions
searchViewController.searchSuggestions = searchSuggestionsM;

} else {
searchViewController.searchSuggestions = nil;
}
}
@end