UISearchDisplayController causes crash after viewDidUnload

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

    So far, I found this working solution for iOS 5 SDK using ARC:

    in .h file, declare your own searchDisplayController property with IBOutlet

    @property (strong, nonatomic) IBOutlet UISearchDisplayController * searchDisplayController;
    

    Then in the .m file, synthesize it:

    @synthesize searchDisplayController;
    

    But don't set it to nil in viewDidUnload.

    So that the search display controller will use the property you create instead of using the inherited property.

    I also notice the similar bug also appear for gesture recognizers (if you create gesture recognizers from the storyboard instead of creating them programmablly). We also need to create STRONG gesture recognizer properties and hook them with the gesture recognizer objects that you create in storyboard. Then in viewDidUnload, don't set them to nil. <-- this prevent the crashes.

提交回复
热议问题