title: Swift Google Place Autocomplete not working wtih Google Maps
body: <p>I am using a search bar to use Google Place Autocomplete feature. However, it is not working when I am putting the search bar on top of GMSMapView. It works completely fine when I comment out loadView() function. Is there a way to use the place autocomplete with Google map?</p>
  
  <pre><code>import UIKit
  import GoogleMaps
  
  class ViewController: UIViewController {
  
    var resultsViewController: GMSAutocompleteResultsViewController?
    var searchController: UISearchController?
    var resultView: UITextView?
  
    override func loadView() {
      let camera = GMSCameraPosition.cameraWithLatitude(1.285, longitude: 103.848, zoom: 12)
      let mapView = GMSMapView.mapWithFrame(.zero, camera: camera)
      self.view = mapView
    }
  
    override func viewDidLoad() {
      super.viewDidLoad()
  
      resultsViewController = GMSAutocompleteResultsViewController()
      resultsViewController?.delegate = self
  
      searchController = UISearchController(searchResultsController: resultsViewController)
      searchController?.searchResultsUpdater = resultsViewController
  
      let subView = UIView(frame: CGRectMake(0, 65.0, 350.0, 45.0))
  
      subView.addSubview((searchController?.searchBar)!)
      self.view.addSubview(subView)
      searchController?.searchBar.sizeToFit()
      searchController?.hidesNavigationBarDuringPresentation = false
  
      // When UISearchController presents the results view, present it in
      // this view controller, not one further up the chain.
      self.definesPresentationContext = true
    }
  }
  
  // Handle the user's selection.
  extension ViewController: GMSAutocompleteResultsViewControllerDelegate {
    func resultsController(resultsController: GMSAutocompleteResultsViewController,
      didAutocompleteWithPlace place: GMSPlace) {
        searchController?.active = false
        // Do something with the selected place.
        print("Place name: ", place.name)
        print("Place address: ", place.formattedAddress)
        print("Place attributions: ", place.attributions)
    }
  
    func resultsController(resultsController: GMSAutocompleteResultsViewController,
      didFailAutocompleteWithError error: NSError){
        // TODO: handle the error.
        print("Error: ", error.description)
    }
  
    // Turn the network activity indicator on and off again.
    func didRequestAutocompletePredictionsForResultsController(resultsController: GMSAutocompleteResultsViewController) {
      UIApplication.sharedApplication().networkActivityIndicatorVisible = true
    }
  
    func didUpdateAutocompletePredictionsForResultsController(resultsController: GMSAutocompleteResultsViewController) {
      UIApplication.sharedApplication().networkActivityIndicatorVisible = false
    }
  }
  </code></pre>
  
  <p>The code above is from <a href="https://developers.google.com/maps/documentation/ios-sdk/map" rel="nofollow">https://developers.google.com/maps/documentation/ios-sdk/map</a> and <a href="https://developers.google.com/places/ios-api/autocomplete" rel="nofollow">https://developers.google.com/places/ios-api/autocomplete</a>. I copied these for testing and is still not working.</p>