UITableView普通样式节标题在搜索视图上重新绘制 [英] UITableView Plain Style Section Header gets Redrawn on Search View
问题描述
当tableView处于搜索栏显示控制器的后台时,是否有人成功重新加载了tableView?看看发生了什么.
Has anyone successfully reloaded a tableView, while the tableView is in the background of a searchbar display controller? See photo with what happens.
我有一个带有搜索显示控制器的UITableViewController.在显示搜索显示控制器的表视图的同时,当我在UITableViewController的表视图上调用reloadData时,UITableViewController的截面视图标题被绘制到搜索显示控制器的视图上.
I have a UITableViewController with a search display controller. When I call reloadData on UITableViewController's tableview while the search display controller's table view is displayed, the section view header from the UITableViewController gets drawn onto the search display controller's view.
以下是快照,该快照在搜索显示控制器视图的顶部显示了部分标题视图:
Here is a snapshot that shows the section title view ontop of the search display controller view:
更新:我将代码简化为简单的搜索显示控制器和UITableView.如果在带有searchBar的tableView上发生重新加载数据.问题仍然存在.
Update: I simplified the code to a simple search display controller and UITableView. If reload data occurs on the tableView with the searchBar active. The issue still happens.
推荐答案
我希望您知道您需要两个 UITableView
才能使搜索栏正常工作.当搜索处于活动状态时,您应该管理并显示搜索结果表,否则将显示原始表.
I hope you know that you need two UITableView
s for a search bar to work. When the search is active, you should manage and display the search results table, otherwise your original one.
摘自Apple文档:The results are displayed in a table view that’s created by the search display controller.
From Apple's documentation: The results are displayed in a table view that’s created by the search display controller.
因此,您不应重新加载原始的UITableView
,而应确保搜索结果表的datasource
是正确的.
UISearchDisplayController
具有一个名为searchResultsTableView
的属性,您无需专门使用reloadData
重新加载.相反,它将通过UISearchDisplayDelegate
协议中的方法(例如searchDisplayController:shouldReloadTableForSearchString:
)进行更新.
UISearchDisplayController
has a property called searchResultsTableView
which you will not have to specifically reload with reloadData
. Rather, it will be updated through the methods in the UISearchDisplayDelegate
protocol, such as searchDisplayController:shouldReloadTableForSearchString:
.
干杯,
萨沙(Sascha)
Cheers,
Sascha
这篇关于UITableView普通样式节标题在搜索视图上重新绘制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!