gpt4 book ai didi

ios - 在 UISearch 显示 Controller 上预加载结果

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:08:04 24 4
gpt4 key购买 nike

我需要实现搜索历史记录。所以我想做的是在尚未输入文本时在搜索显示 Controller 中显示历史记录。

我实现了这个:

-(void)searchDisplayControllerDidBeginSearch:(UISearchDisplayController *)controller{
self.searchDisplayController.searchResultsTableView.hidden=NO;
}

还有这个:

- (void)searchDisplayController:(UISearchDisplayController *)controller didHideSearchResultsTableView:(UITableView *)tableView{
self.searchDisplayController.searchResultsTableView.hidden=NO;
}

使表格始终显示。

我还实现了行数来区分案例:(我也处理了cellForIndexpath,但不需要在这里显示)

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
if ([self.searchDisplayController.searchBar.text isEqualToString:@""]) {
NSArray* d=[DropsAppDelegate getSharedInstance].userData.getLastSearches;
return d.count;
}
return [searchResultPlaces count];
}

但这会造成困惑。表格显示在半透明屏幕后面,在退出搜索时变得可见。 the history results

而且当我实际输入内容时,屏幕不会关闭。我该怎么做才能使 UITableView 始终显示?我查看了所有答案,但没有任何答案适用于 iOS7。

最佳答案

你好像在和UISearchDisplayController打架,它一直都有些吝啬,在iOS7上更是如此。

我的建议是不要使用它,而是使用搜索栏实现您需要的内容。这真的没那么难,你会得到你需要的一切委托(delegate)回调,而且你不会与技术作对。 UISearchBarDelegate讲述了整个故事。

关于ios - 在 UISearch 显示 Controller 上预加载结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21512804/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com