UISearchDisplayController causes crash after viewDidUnload

后端 未结 7 1764
温柔的废话
温柔的废话 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:25

    Explicitly declare your outlet 
    
    @property (nonatomic, strong) IBOutlet UISearchDisplayController *searchDisplayController;
    
    
    Then in dealloc - add these lines - nil out the delegate / data source so that they do not receive any message further when the searchDisplayController deallocates itself.
    
    self.searchDisplayController.delegate = nil;
    self.searchDisplayController.searchResultsDelegate = nil;
    self.searchDisplayController.searchResultsDataSource = nil;
    

提交回复
热议问题