更改后,tabBarItem TableViewController看起来像黑屏

时间:2018-10-04 04:03:40

标签: swift uitableview uitabbaritem

我有带搜索栏的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)

    }

UITableView work like need

Change TabBarItem

TableView don't work

1 个答案:

答案 0 :(得分:0)

class SearchController: UISearchController {

    override func viewWillDisappear(_ animated: Bool) {        
        // to avoid black screen when switching tabs while searching
        isActive = false
    }
}