我在界面构建器b<中编写了一个SearchBar,但没有将搜索拖到tableView中。在另一个TabelView中显示SearchResult。搜索效果很好。但每次我搜索的时候,它都会显示这个SearchResult Popover。我可以删除此弹出窗口吗?
` `SetShowsSearchResultsButton self.searchDisplayController.searchBar:否;`也不起作用
下面是一些代码
- (BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString
{
[appDelegate.searchSource removeAllObjects];
if (0 == [searchString length]) {
NSLog(@"LEER");
appDelegate.gefunden=NO;
[appDelegate.rootViewController.tableView.tableView reloadData];
[SearchBar1 resignFirstResponder];
}
for (NSArray *myPoi in appDelegate.poiList)
{
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(SELF contains[c] %@)", searchString];
BOOL resultName = [predicate evaluateWithObject:[myPoi valueForKey:@"name"]];
if (resultName) {
appDelegate.gefunden = YES;
[appDelegate.searchSource addObject:myPoi];
[appDelegate.rootViewController.tableView.tableView reloadData];
[self.searchDisplayController setActive:NO animated:YES];
[self.SearchBar1 becomeFirstResponder];
}
}
return YES;
}在viewdidload中
self.searchDisplayController.searchResultsDataSource = appDelegate.rootViewController.tableView.tableView.dataSource;谢谢
发布于 2011-05-27 22:14:06
在IB中,尝试将SearchDisplayController的searchResultsDelegate、searchResultsDataSource、searchContentsController值设置为Files Owner,然后将代码从
- (BOOL)searchDisplayController:(UISearchDisplayController*)controller shouldReloadTableForSearchString:(NSString*)searchString至
- (void)searchBar:(UISearchBar*)searchBar textDidChange:(NSString*)searchText这应该能起到作用。
发布于 2014-06-17 13:04:32
您可以通过在搜索结束后将控制器设置为非活动状态来完成此操作:
- (void) searchDisplayControllerDidEndSearch:(UISearchDisplayController *)controller{
[controller setActive:NO animated:YES];
}https://stackoverflow.com/questions/6136158
复制相似问题