UISearchDisplayController causes crash after viewDidUnload

后端 未结 7 1742
温柔的废话
温柔的废话 2020-12-14 09:50

I have a project using StoryBoards and UISearchDisplayController used in the context of a UINavigationController, that appears in the root viewcont

7条回答
  •  攒了一身酷
    2020-12-14 10:44

    @Wayne: I had run into the same issue with a SearchDisplayController created from a Storyboard, and spend over a day trying to debug a crash that seemed to appear when none of my code was running. In my case the symptom was the user taps a tab in UITabBarController to return to a ViewController that has been unloaded after a memory warning. The unloaded view controller's viewDidLoad method never runs and the code gets at least as far as tabBarController:didSelectViewController: (which should run after viewDidLoad) before it crashes somewhere in the assembly code!

    Thanks massively for posting this workaround and for all the follow-ups. A small improvement is to move your UIDisplayController instantiation to a lazily loaded accessor method for the searchDisplayController property. The practical effect is negligible but it looks nicer!

提交回复
热议问题