ios - 如何使用搜索栏过滤器解决错误,然后快速展开 segue?
问题描述
我目前在 mainPage( viewController
) - tableView in viewController
> searchbarPage( ) -> subPage( viewController
) 顺序中有一个屏幕。
subPage 有一个back button
并使用unwind segue
. 然后按back button
返回主页面。
在 searchbarPage 中,选择tableViewcell
不应用过滤器,将其移动到子页面,按返回按钮,unwind segue 将正常工作。
但是,当我使用过滤器转到子页面searchbar
并按后退按钮时,会发生错误。
我不知道为什么会这样。
// Unwind Segue - mainPage
@IBAction func gotoMainPage(_ sender: UIStoryboardSegue){
}
// Search Bar filter - search Page
func updateSearchResults(for searchController: UISearchController) {
if searchController.searchBar.text! == "" {
self.filterSearch = self.MainDAO.find() // sqlite select
} else {
self.filterSearch = self.MainDAO.find().filter( {$0.itemName.lowercased().contains(searchController.searchBar.text!.lowercased()) })
}
self.tableView.reloadData()
}
解决方案
尝试使用此代码,它将帮助您它对我有用
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)
{
searchController?.isActive = false // Add this !
dismiss(animated: true)
}
推荐阅读
- entitymanager - Quarkus:具有多个数据源的 EntityManager 注入
- javascript - 如何读取 JxBrowser 捕获的自定义事件的属性
- c# - 相当于 VS Code 中的解决方案文件夹
- html - 反应js css样式在与标题字符串相同的行上获得令人敬畏的字体图标
- amazon-web-services - 如何从您的公司 AD 或 LDAP 目录执行 SSO 并限制每个用户对存储桶中指定用户文件夹的访问?
- gnuplot - 有没有办法在 pm3d 图上翻转 x 和 y 轴
- paypal - Paypal 开发者/企业帐户(沙盒)
- spring-boot - JSON解析错误:无法反序列化`java.lang.Long的实例
- python-3.x - 如何使用 python 从云函数将数据帧加载到 BigQuery 分区表中
- java - Android AWS S3 Upload TransferUtility错误上传部分中断:超时和套接字关闭