UISearchDisplayController与UITableViewController [英] UISearchDisplayController with UITableViewController

查看:105
本文介绍了UISearchDisplayController与UITableViewController的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 UITableViewController ,其中我添加了一个UISearchBar作为 tableHeaderView 使用Interface Builder。然后我在nib中添加了一个 UISearchDisplayController ,并设置所有连接( delegate searchResultsDelegate searchContentsController searchResultsDataSource ,所有连接到 UITableViewController )。
然后我在代码中实现了所有的委托和数据源方法。



它像一个charm,除了一个奇怪的bug:有时搜索结果表视图不会滚动,我可以看到它后面的主表视图的闪光指示器。我NSLog的 searchResultsTableView 并且显然它是一个主视图的子视图,我想这是触摸问题我之前描述的背后的原因。



我的错误是什么?是否可以使用 UITableViewController UISearchDisplayController ?如果是这样,我如何设置它的方式,结果表视图不添加为我的主表视图的子视图?



更新:我发现 / UITableViewController ,显然搜索表视图也被添加到主表视图中。所以现在我不认为这是我的问题。



事情是我找不到我在做什么和样本在做什么之间的任何实质性的差异。我只是在 UITableViewController 中添加 UISearchBar 作为 UITableView $ c>并添加一个 UISearchDisplayController ...它就像当我尝试滚动时,主表和搜索表之间的混淆。你有什么想法吗?



更新:添加了200个代表。

>

p>这是一个额外的 self.tableView.scrollEnabled = YES ,一旦搜索数据请求完成调用。希望它能帮助未来有同样问题的任何人。


I have a UITableViewController, in which I added a UISearchBar as the tableHeaderView using Interface Builder. Then I added a UISearchDisplayController in the nib, and set up all the connections (delegate, searchResultsDelegate, searchContentsController, searchResultsDataSource, all connected to the UITableViewController). I then implemented all the delegate and data source methods in my code.

It works like a charm, except for a weird bug: sometimes the search results table view won't scroll, and I can see the flash indicator of the main table view behind it. I NSLog'd the searchResultsTableView and apparently it's a subview of the main tableview, and I guess that's the reason behind the touch problems I described earlier.

What's my mistake? Is it possible to use a UITableViewController with UISearchDisplayController at all? If so, how do I set up it in such a way that the results table view doesn't get added as a subview of my main table view?

Update: I found this sample which uses UISearchDisplayController with UITableViewController and apparently the search table view gets added to the main table view in there as well. So now I don't think that's my problem.

The thing is that I can't find any substantial difference between what I'm doing and what that sample is doing. I'm just adding an UISearchBar as a UITableView header in a UITableViewController and adding a UISearchDisplayController to it... It's like iOS is confused between the main table and the search table when I try to scroll. Do you have any ideas?

Update: Added a 200 rep bounty. Please answer only if you know what you're talking about.

解决方案

It was an extra self.tableView.scrollEnabled = YES which was called as soon as the search data request was finished. Hope it helps anyone with the same problem in the future.

这篇关于UISearchDisplayController与UITableViewController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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