首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >从SearchDisplayController中取消Popover

从SearchDisplayController中取消Popover
EN

Stack Overflow用户
提问于 2011-05-26 17:09:22
回答 2查看 775关注 0票数 1

我在界面构建器b<中编写了一个SearchBar,但没有将搜索拖到tableView中。在另一个TabelView中显示SearchResult。搜索效果很好。但每次我搜索的时候,它都会显示这个SearchResult Popover。我可以删除此弹出窗口吗?

` `SetShowsSearchResultsButton self.searchDisplayController.searchBar:否;`也不起作用

下面是一些代码

代码语言:javascript
复制
- (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中

代码语言:javascript
复制
self.searchDisplayController.searchResultsDataSource = appDelegate.rootViewController.tableView.tableView.dataSource;

谢谢

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2011-05-27 22:14:06

在IB中,尝试将SearchDisplayController的searchResultsDelegate、searchResultsDataSource、searchContentsController值设置为Files Owner,然后将代码从

代码语言:javascript
复制
- (BOOL)searchDisplayController:(UISearchDisplayController*)controller shouldReloadTableForSearchString:(NSString*)searchString

代码语言:javascript
复制
- (void)searchBar:(UISearchBar*)searchBar textDidChange:(NSString*)searchText

这应该能起到作用。

票数 1
EN

Stack Overflow用户

发布于 2014-06-17 13:04:32

您可以通过在搜索结束后将控制器设置为非活动状态来完成此操作:

代码语言:javascript
复制
- (void) searchDisplayControllerDidEndSearch:(UISearchDisplayController *)controller{

    [controller setActive:NO animated:YES];
}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/6136158

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档