如何解决从SearchDisplayController中关闭弹出窗口
| 我在界面生成器中编程了SearchBar但没有其他操作b <将搜索拖动到tableView。 SearchResult在另一个TabelView中显示。搜索效果很好。但是每次我搜索它都会显示此SearchResult Popover。我可以删除此Popover吗? [SetShowsSearchResultsButton self.searchDisplayController.searchBar: NO];
这也行不通
这是一些代码
- (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;
谢谢
解决方法
在IB中,尝试将SearchDisplayController的searchResultsDelegate,searchResultsDataSource,searchContentsController值设置为Files Owner,然后将代码从
- (BOOL)searchDisplayController:(UISearchDisplayController*)controller shouldReloadTableForSearchString:(NSString*)searchString
至
- (void)searchBar:(UISearchBar*)searchBar textDidChange:(NSString*)searchText
这应该够了吧。
,您可以通过在搜索结束后将控制器设置为非活动状态来执行此操作:
- (void) searchDisplayControllerDidEndSearch:(UISearchDisplayController *)controller{
[controller setActive:NO animated:YES];
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。