UITableView普通样式节标题在搜索视图上重新绘制 [英] UITableView Plain Style Section Header gets Redrawn on Search View

查看:77
本文介绍了UITableView普通样式节标题在搜索视图上重新绘制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当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 UITableViews 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屋!

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