swift - UISearchController 在查询为空时隐藏 tableView
问题描述
不知何故,当我的搜索字符串为空时,即使我的数据数组仍然保存信息并且numberOfRowsInSection
/numberOfSections
仍然返回相应的信息,tableView 也被隐藏了。
我将此代码放入我的UISearchResultsUpdating
(searchResultsUpdater):
func updateSearchResults(for searchController: UISearchController) {
print(tableView.isHidden)
// my program logic to fetch data with that string from server
// and reload the tableView
}
它明确指出,一旦我删除搜索栏中的所有文本,该isHidden
属性就会设置为。
现在,在你可以看到的确切位置,我放了,但应该有更好的方法,类似或沿着这些思路。true
print()
tableView.isHidden = false
hideTableViewWhenSearchEmpty
提前致谢!
解决方案
推荐阅读
- python - 使用鼠标事件绘制模糊矩形
- javascript - Laravel 5.8 中外部 js 文件上的“405 Method not allowed”
- google-cloud-platform - GCP Dataproc 并行步骤执行
- html-email - 阻止 SES 将 awstrack.me 添加到我的所有电子邮件链接
- javascript - 如何访问以下 json 值
- django - Django ORM - 获取具有 OneToOneField 的多个 select_related
- android - 在 Facebook Canvas 上的存在,appwarp android 游戏
- java - BMI 计算器 NaN 输出
- css - Spring MVC,无法加载背景图片
- python - 删除具有相同日期时间的行