ViewWillDisappear not getting called searchcontroller

后端 未结 3 836
庸人自扰
庸人自扰 2021-02-15 09:41

When I\'m in the middle of a search and then switch UItabs, ViewWillDisappear does not get called. Any idea as to why ViewWillDisappear does not get called when I have filtere

3条回答
  •  有刺的猬
    2021-02-15 10:08

    Had the same issue. viewWillDisappear is not called on the UITableViewController, but it is called in the UISearchController.

    So I subclassed UISearchController and overrode the viewWillDisappear method. In my case I just needed to deactivate the search controller.

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

提交回复
热议问题