在搜索方法迭代完成后,重新加载/显示UISearchDisplayController的searchResultsTableView [英] Reloading / Displaying searchResultsTableView of UISearchDisplayController after search method iteration is finished

查看:76
本文介绍了在搜索方法迭代完成后,重新加载/显示UISearchDisplayController的searchResultsTableView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已修改Apple示例iOS项目的代码 TableSearch ,以便使用它通过解析其内容来搜索Web服务。所有我实现的工作正常,除了一个丑陋的细节,当使用SearchDisplayController的SearchBar执行搜索。我改变了SearchDisplayController的行为,使其在搜索按钮被点击时首先调用我的搜索功能。



问题是当搜索迭代是在NSOperationQueue的后台执行的)完成后,searchResultsTableView(searchDisplayController)不会自动显示或不分配结果内容。如果您随后更改SearchBar的文本或点击触摸搜索字段(请参阅TableSearch)时显示的视图中的取消按钮,则会显示正确的TableView和搜索结果。我只想让这一步在搜索操作完成后立即执行,所以在交互之前。在此阶段,当前显示无结果标签。方法filterContentForSearchText和shouldReloadTableForSearchString与原来的TableSearch项目保持不变。



我已经看到了SearchDisplayController的不同类引用及其属性,但我可以没有找到任何最终解决方案。



我已经尝试了下面的部分,这是肯定是迭代的NSOperation完成后,但似乎并没有解决问题。 / p>

  [self.searchDisplayController.searchResultsTableView removeFromSuperview];  

  self.searchDisplayController.searchResultsTableView.hidden = YES;  

这些操作都有我想要显示的正确视图。但是,在您更改状态以使视图再次隐藏之前,滚动将被禁用。但是可以选择TableView单元格。


>解决方案

我有同样的问题,我刚解决了。我有完全相同的问题,我想禁用即时搜索,当我点击搜索按钮,表没有加载,但当我点击取消,它加载。如果我在表视图上滚动,在搜索后没有加载正确的结果,它崩溃,由于索引超出边界。



你需要做的事情是重新加载searchResultTableView不是当前tableview。在按搜索字词过滤出您的数据后,请放入

  [self.searchDisplayController.searchResultsTableView reloadData] 

重新载入您的搜索结果,它会在您按下搜索按钮后显示。
希望此帮助


I have modified the code of Apple's sample iOS project TableSearch in order to use it for searching a webservice by parsing its contents. Everything I have implemented works fine except for one ugly detail when performing a search using the SearchDisplayController's SearchBar. I have changed the behaviour of the SearchDisplayController to make it call my search function first when the "Search" button was tapped.

The problem is that when the search iteration (which is performed in the background in an NSOperationQueue) is finished the "searchResultsTableView" (of the searchDisplayController) is not automatically displayed or not assigned the resulting content. If you then change the SearchBar's text or tap the "Cancel" button from the view which appears when you touch the search field (see TableSearch) the correct TableView appears with the search results. I simply want to have this step to be executed right after the search operation is finished, so before you interact. At this stage the "No Results" label is currently displayed. The methods "filterContentForSearchText" and "shouldReloadTableForSearchString" are unchanged from the original TableSearch project.

I have taken a look at different class references of the SearchDisplayController and its attributes but I could not find any final solution yet.

I have tried the following in a section which is definitely iterated after the NSOperation is finished but it does not seem to solve the problem.

[self.searchDisplayController.searchResultsTableView removeFromSuperview];

and

self.searchDisplayController.searchResultsTableView.hidden = YES;

These operations both have the correct view I want displayed BUT scrolling is disabled until you change the state so that the view is hidden again. It is possible to select TableView cells, though. I basically want to have this just with scrolling enabled...

Thanks in advance for your effort!

解决方案

I have same problem and I just solved it. I had exactly same problem, I wanted disable instant search and when I hit search button, the table didn't load but when I clicked cancel, it loaded up. And If I scroll on table view that didn't load correct result after search, it crashed due to index out of bound.

The thing you need to do is reload searchResultTableView not current tableview. After you filter out your data by search term, put

[self.searchDisplayController.searchResultsTableView reloadData]

to reload your search result, and it will shows up after you hit search button. Hope this help

这篇关于在搜索方法迭代完成后,重新加载/显示UISearchDisplayController的searchResultsTableView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆