Back Button of NavBar Tapped when Incrementally Searching using SearchBarNavigationBar, search function cannot act correctly
Environment
Situation
- Implement Incremental Search in TableViewController using SearchBar
- Input search word
- Leave by back button of nav bar, not x button or cancel button
- Search cannot move correctly.
Initial View of Search
FirstResponder moves to search bar, and ....
date become vacant
incremental search
By inputting a character, result change.
But
Leave by back button of navigation item, not x button or cancel button, try to search again, and never go well.
Cannot search correctly. Data does not change cancel button never been shown
solution
-set active of UISearchController false in viewWillDisappear
var resultSearchController = UISearchController() override func viewWillDisappear(animated: Bool) { self.resultSearchController.active = false }
Solved well.