title: How should I present a UISearchController using a UISplitView adaptive user interface?
body: <p>Using a universal storyboard with an adaptive <code>UISplitViewController</code> user interface.</p>
  
  <p>I want to present a search controller on the primary (master) side, using the following code (from the master view controller):</p>
  
  <pre><code>static NSString * const kCGISearchViewControllerID = @"SearchViewControllerID";
  
  - (IBAction)searchButtonClicked:(UIBarButtonItem *)__unused sender {
      SearchViewController *searchResultsController = [self.storyboard instantiateViewControllerWithIdentifier:kCGISearchViewControllerID];
      self.searchController = [[UISearchController alloc] initWithSearchResultsController:searchResultsController];
      self.searchController.searchResultsUpdater = searchResultsController;
      self.searchController.hidesNavigationBarDuringPresentation = NO;
      [self presentViewController:self.searchController animated:YES completion:nil];
  }
  </code></pre>
  
  <p>It initially appears to work correctly (regardless of the starting orientation):</p>
  
  <p><img src="https://i.stack.imgur.com/PoO0H.png" alt="Landscape starts out looking ok"></p>
  
  <p>Problems show up after autorotation (keyboard still visible, underlying content still dimmed, but the search bar has disappeared):</p>
  
  <p><img src="https://i.stack.imgur.com/V91vt.png" alt="enter image description here"></p>
  
  <p>Upon rotating back to landscape, the search bar reappears, but its width is now wrong:</p>
  
  <p><img src="https://i.stack.imgur.com/CmmvG.png" alt="enter image description here"></p>
  
  <p>(I've also tried placing the search controller's <code>searchBar</code> in the <code>titleView</code>.  While the searchBar adapts correctly, the search results controller still doesn't look right.)</p>
  
  <p>What am I missing to get a presented <code>UISearchController</code> to animate itself properly as the UI adapts to changing size classes?</p>
  
  <p><strong>Update:</strong></p>
  
  <p>Adding <code>self.definesPresentationContext = YES;</code> gets the search bar/results to appear within the primary view, but the search bar is animating <em>under</em> that navigation bar, and isn't visible.  The other issue is that the search bar height doesn't shrink, when it rotates from portrait (which has a status bar), back to landscape.</p>