title: programmatically use UISearchDisplayController
body: <p>I have an app which asynchronously searches a remote API and displays the UI using iOS' UISearchDisplayController.</p>
  
  <p>For a saved search feature, I've been trying to programmatically use the UISearchDisplayController, in order to both initiate the search, and set up the user interface to be right back where he used to be. (Ie., I'm trying to bring up the search bar and set the search term.)</p>
  
  <pre><code>searchTableViewController.searchDisplayController.searchBar.text = mySearchTerm;
  //[...]
  [searchTableViewController.searchDisplayController setActive:YES animated:YES];
  [searchTableViewController performSearch];
  </code></pre>
  
  <p>The code I've tried so far—above—doesn't seem to do the trick. While it correctly brings up the search bar, sets the search term and performs a search, the system doesn't seem to recognize this as a valid search somehow. If I use my fingers in the results view to make the keyboard disappear, the search term resets itself and the results disappear.</p>
  
  <p><img src="https://i.stack.imgur.com/B8Xqh.jpg" alt="ex1">
  <img src="https://i.stack.imgur.com/ZigCy.jpg" alt="ex2"></p>
  
  <p>Help appreciated. Thanks!</p>