0

I have TableViewController with search bar, after update updateSearchResults it work and when I change TabBarItem and come back I have a black screen, may be somebody had this problem? How I understand, I should clear tableview in viewWillDisappear

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)

    }

UITableView work like need

Change TabBarItem

TableView don't work

1 Answers1

0
class SearchController: UISearchController {

    override func viewWillDisappear(_ animated: Bool) {        
        // to avoid black screen when switching tabs while searching
        isActive = false
    }
}
Nikunj Kumbhani
  • 3,758
  • 2
  • 26
  • 51
  • Please provide some explanation about what your code does and why it answers the question. In this case, what is `isActive` actually doing and where to put this code? – Crazyrems Oct 04 '18 at 08:26
  • Crazyrems! Sorry, I'm newbie in StackOverflow I find this problem https://stackoverflow.com/questions/36938239/tab-bar-and-uisearchcontroller-giving-black-screen –  Oct 04 '18 at 20:33