title: UISearchController does not display as expected
body: <p>I'm trying to add a UISearchController to a UIViewController that contains a UITableView (and an MKMapView too, but hopefully that's not the problem). I followed <a href="https://www.raywenderlich.com/157864/uisearchcontroller-tutorial-getting-started" rel="nofollow noreferrer">Ray Wenderlich's tutorial</a> but I can't get the same result in terms of behaviour.</p>
  
  <p>Here is my viewDidLoad:</p>
  
  <pre><code>override func viewDidLoad() {
          super.viewDidLoad()
  
          // Setup the Search Controller
          searchController.searchResultsUpdater = self
          searchController.obscuresBackgroundDuringPresentation = false
          searchController.searchBar.placeholder = NSLocalizedString("Search references by project, customer or city", comment: "")
          if #available(iOS 11.0, *) {
              navigationItem.searchController = searchController
              navigationItem.hidesSearchBarWhenScrolling = true
          } else {
              tableView.tableHeaderView = searchController.searchBar
          }
          definesPresentationContext = true
  
          self.modeSelector.layer.cornerRadius = 5.0
  
          if let split = splitViewController {
              let controllers = split.viewControllers
              detailViewController = (controllers[controllers.count - 1] as! UINavigationController).topViewController as? ReferenceViewController
          }
  
          self.navigationItem.rightBarButtonItem?.isEnabled = false
      }
  </code></pre>
  
  <p>Note that the #available test in the middle is because I need to support iOS up to 9.1.</p>
  
  <p>Now I see several problems:</p>
  
  <ul>
  <li>The search bar appears right away and I can't hide it by scrolling</li>
  <li>When I focus the search bar, the top of the tableview doesn't stick to the bottom of the navigation item:</li>
  </ul>
  
  <p><a href="https://i.stack.imgur.com/wKQ39.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wKQ39.png" alt="enter image description here"></a></p>
  
  <p>The only major difference I see with Ray Wenderlich's sample project is that since I created my project with Xcode 9, my storyboard doesn't use top and bottom layout guides, but safe areas. Don't know if it's relevant, but that's the only thing I see.</p>
  
  <p>Any idea what's going on and how I could fix this?</p>