title: How to Make autoLayout for UISearchController when rotate the device?
body: <p>I'm using a UISearchController integrate with my tableview. For making my searchBar not scrolling with the table, I already made a View (name SearchBarView) under the navigation bar and my table is under this view. All element on my view is setting up using auto layout:
  <img src="https://i.stack.imgur.com/XmHJs.png" alt="enter image description here"></p>
  
  <p>In my code. I make a UISearchController like a subview of SearchBarView and using sideToFit function for auto fit the width of the screen like this:</p>
  
  <pre><code>      self.resultSeachController = ({
              let controller = UISearchController(searchResultsController: nil)
              controller.searchResultsUpdater = self
              controller.dimsBackgroundDuringPresentation = false
              controller.searchBar.sizeToFit()
  
  //            add searchbar in the searchbarView
              self.searchBarView.addSubview(controller.searchBar)
              return controller
          })()
  </code></pre>
  
  <p>My SearchBar is working perfect now except one: when I rotate the simulator, the searchBar is not automatic fit the width of screen. It only fit the screen when I touch the SearchBar for searching something.
  <img src="https://i.stack.imgur.com/OzMVi.png" alt="enter image description here">
  <img src="https://i.stack.imgur.com/TmtW9.png" alt="enter image description here">
  <img src="https://i.stack.imgur.com/CdFdu.png" alt="enter image description here">
  <img src="https://i.stack.imgur.com/oq6OY.png" alt="enter image description here"></p>
  
  <p>I don't know how to fix. I tried this code :</p>
  
  <pre><code>    override func viewWillTransitionToSize(size: CGSize, withTransitionCoordinator coordinator: UIViewControllerTransitionCoordinator) {
  
          self.resultSeachController.searchBar.sizeToFit()
  
      }
  </code></pre>
  
  <p>But It's still not working. How can I fix that? </p>