Attempting to load the view of a view controller while it is deallocating… UISearchController

前端 未结 13 1145
一生所求
一生所求 2020-12-01 02:34

I have code that creates a UISearchController\' in my UIVIew\'sviewDidLoad`.

 self.resultSearchController = ({
        let controller = UISearch         


        
13条回答
  •  不思量自难忘°
    2020-12-01 02:54

    I used Derek's answer, but had to change it slightly. The answer that was provided crashed for me because the call to loadViewIfNeeded() happened before the resultSearchController was defined. (My declaration was

    var resultSearchController: UISearchController!
    

    ). So I just moved it afterwards and it worked.

    If I left out the call entirely, the bug remained, so I'm sure it is an essential part of the answer. I was unable to test it on iOS 8.

提交回复
热议问题