I have implemented UISearchbar in UISearchController which is placed inside a UIView. But the searchbar doesn't fit correctly in iPad..In iPhone , it works correctly by setting sizeToFit and the frame.size.width as per the stack overflow answers. Please help me to work with iPad also. I followed the answer in this link - Display UISearchController's searchbar programmatically
var pickUpresultsViewController: GMSAutocompleteResultsViewController?
var pickUpSearchController: UISearchController?
pickUpresultsViewController = GMSAutocompleteResultsViewController()
pickUpresultsViewController?.delegate = self
pickUpSearchController = UISearchController(searchResultsController: pickUpresultsViewController)
pickUpSearchController?.searchResultsUpdater = pickUpresultsViewController
pickUpSearchController?.searchBar.placeholder = "From:"
pickUpView.addSubview((pickUpSearchController?.searchBar)!)
pickUpSearchController?.searchBar.sizeToFit()
// For some reason, the search bar will extend outside the view to the left after calling sizeToFit. This next line corrects this.
pickUpSearchController?.searchBar.frame.size.width = pickUpView.frame.size.width
definesPresentationContext = true
pickUpSearchController?.hidesNavigationBarDuringPresentation = false