我UISearchDisplayController
通过NSOperationQueue
.
然而,结果表直到NSOperation
调用后大约 5 秒才直观地更新[searchDisplayController.searchResultsTableView reloadData]
。
- (BOOL) searchDisplayController:(UISearchDisplayController*)controller shouldReloadTableForSearchString:(NSString*)searchString
{
[searchQueue cancelAllOperations];
NSInvocationOperation *op = [[[CustomSearchOperation alloc] initWithController:controller searchTerm:searchString] autorelease];
[searchQueue addOperation:op];
return NO;
}
我的 CustomerSearchOperation 像这样更新 tableView:
- (void) main
{
// perform search
[searchDisplayController setContents:results];
[searchDisplayController.searchResultsTableView reloadData];
}