我有带搜索栏的TableViewController,在更新updateSearchResults之后可以正常工作,当我更改TabBarItem并回来时出现黑屏,可能有人遇到了这个问题吗?我的理解方式,我应该清除 viewWillDisappear中的tableview
override func viewWillAppear(_ animated: Bool) {
setNavigationBar()
tableView.register(NewMessageTableViewCell.self, forCellReuseIdentifier: "cell")
tableView.tableFooterView = UIView()
super.viewWillAppear(animated)
}
override func viewWillDisappear(_ animated: Bool) {
searchUsers.removeAll()
searchController.searchBar.text = nil
tableView.endUpdates()
super.viewWillDisappear(animated)
}
答案 0 :(得分:0)
class SearchController: UISearchController {
override func viewWillDisappear(_ animated: Bool) {
// to avoid black screen when switching tabs while searching
isActive = false
}
}