我想在搜索栏激活后立即显示过去的搜索。但是即使数据源有这些值,搜索显示 Controller 在用户开始输入之前不会调用 TableView 方法。有没有办法在 UISearchDisplayController 上强制执行此操作?
最佳答案
只要您的代理设置正确,您就可以返回任何您想要的数据集。
self.searchResults = @[@"some stuff", @"some more stuff", @"and so on..."];
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
if (tableView == [[self searchDisplayController] searchResultsTableView]) {
return [self.searchResults count];
}
else {
return [self.data count];
}
}
关于iphone - 有没有办法在用户开始在 SearchBar 中输入之前用结果预填充 UISearchDisplayController?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11409166/