How to activate a UISearchDisplayController

- by

We can do this two ways:

    // version 1:
    [self.searchBar becomeFirstResponder];

    // version 2:
    [self.searchDisplayController setActive:YES animated:YES];

The benefit of version 2 is that if we perform it “in vision”, we can use the animated option and make it look all swish.

Version 2 of course also has a reverse with which we can deactivate the controller:

    [self.searchDisplayController setActive:NO animated:YES];

Note that this will not affect the UISearchBar associated with the search display controller; you need to deal with that separately.



If you enjoy my content, please consider supporting me on Ko-fi. In return you can browse this whole site without any pesky ads! More details here.

Leave a Comment!

This site uses Akismet to reduce spam. Learn how your comment data is processed.