title: How to change from UISearchDisplayController deprecated in iOS 8.0 to UISearchController
body: <p>I used <code>UISearchController</code> since learning that <code>UISearchDisplayController</code> is deprecated. But now have a problem, integrating with <a href="https://github.com/chenyuan/SPGooglePlacesAutocomplete/issues/20" rel="nofollow noreferrer">SPGooglePlacesAutocomplete</a> forked library by Chenyuan in GitHub.</p>
  
  <p>I get the search bar when I start typing no results are displayed. What I am also wondering is if UISearchDisplayController is deprecated how, come Chenyuan Demo run without warning or issue of deprecated methods. </p>
  
  <p>Here is my code snippet which I attempted to convert his demo to UISearchController, please tell me where I'm going wrong. </p>
  
  <p>MainViewController.h</p>
  
  <pre><code>    #import &lt;UIKit/UIKit.h&gt;
  #import &lt;MapKit/MapKit.h&gt;
  #define IS_OS_8_OR_LATER ([[[UIDevice currentDevice] systemVersion] floatValue] &gt;= 8.0)
  @class SPGooglePlacesAutocompleteQuery;
  
  @interface MainViewController : UIViewController &lt;MKMapViewDelegate, CLLocationManagerDelegate,
  UISearchBarDelegate,
  UISearchControllerDelegate,
  UITableViewDataSource,
  UITableViewDelegate&gt;{
      NSArray *searchResultPlaces;
      SPGooglePlacesAutocompleteQuery *searchQuery;
      MKPointAnnotation *selectedPlaceAnnotation;
  
      BOOL shouldBeginEditing;
  
  @private
      CGRect _searchTableViewRect;
  }
  
  // Search
  @property (strong, nonatomic) UISearchDisplayController *searchController;
  @property (strong, nonatomic) MKLocalSearch *localSearch;
  @property (strong, nonatomic) MKLocalSearchResponse *results;
  
  @end
  </code></pre>
  
  <p>MainViewController.m snippet</p>
  
  <pre><code>  // setup Search Controller
  -(void) setupSearchController {
  
      // The TableViewController used to display the results of a search
      UITableViewController *searchResultsController = [[UITableViewController alloc] initWithStyle:UITableViewStylePlain];
      searchResultsController.automaticallyAdjustsScrollViewInsets = NO; // Remove table view insets
      searchResultsController.tableView.dataSource = self;
      searchResultsController.tableView.delegate = self;
  
      // Initialize our UISearchController
      self.searchController = [[UISearchController alloc] initWithSearchResultsController:searchResultsController];
      self.searchController.delegate = self;
      self.searchController.searchBar.delegate = self;
      // Hint for the search
  
      self.searchController.searchBar.placeholder = @"Search your destination address";
  
  }
  
  // Setup Search Bar
  -(void) setupSearchBar {
  
      // Set search bar dimension and position
      CGRect searchBarFrame = self.searchController.searchBar.frame;
      CGRect viewFrame = self.view.frame;
      self.searchController.searchBar.frame = CGRectMake(searchBarFrame.origin.x,
                                                         searchBarFrame.origin.y,
                                                         viewFrame.size.width,
                                                         44.0);
  
      // Add SearchController's search bar to our view and bring it to front
      [self.view addSubview:self.searchController.searchBar];
      [self.view bringSubviewToFront:self.searchController.searchBar];
  
  }
  </code></pre>
  
  <p>continuation of the MainViewController.m</p>
  
  <pre><code>-(void)willPresentSearchController:(UISearchController *)aSearchController {
  
      aSearchController.searchBar.bounds = CGRectInset(aSearchController.searchBar.frame, 0.0f, 0.0f);
  
      // Set the position of the result's table view below the status bar and search bar
      // Use of instance variable to do it only once, otherwise it goes down at every search request
      if (CGRectIsEmpty(_searchTableViewRect)) {
          CGRect tableViewFrame = ((UITableViewController *)aSearchController.searchResultsController).tableView
          .frame;
          tableViewFrame.origin.y = tableViewFrame.origin.y + 64; //status bar (20) + nav bar (44)
          tableViewFrame.size.height =  tableViewFrame.size.height;
  
          _searchTableViewRect = tableViewFrame;
      }
  
      [((UITableViewController *)aSearchController.searchResultsController).tableView setFrame:_searchTableViewRect];
  }
  
  #pragma mark -
  #pragma mark UISearchDisplayDelegate
  
  - (void)handleSearchForSearchString:(NSString *)searchString {
      searchQuery.location = self.mapView.userLocation.coordinate;
      searchQuery.input = searchString;
      [searchQuery fetchPlaces:^(NSArray *places, NSError *error) {
          if (error) {
              UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Could not fetch Places"
                                                              message:error.localizedDescription
                                                             delegate:nil
                                                    cancelButtonTitle:@"OK"
                                                    otherButtonTitles:nil, nil];
              [alert show];
          } else {
              searchResultPlaces = places;
              // [self.searchController.searchResultsTableView reloadData];
              [[(UITableViewController *)self.searchController.searchResultsController tableView] reloadData];
          }
      }];
  }
  
  - (BOOL)searchController:(UISearchController *)controller shouldReloadTableForSearchString:(NSString *)searchString {
      [self handleSearchForSearchString:searchString];
  
      // Return YES to cause the search result table view to be reloaded.
      return YES;
  }
  
  - (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText {
  
      if (![searchBar isFirstResponder]) {
          // User tapped the 'clear' button.
          shouldBeginEditing = NO;
          [self.searchController setActive:NO];
          [self.mapView removeAnnotation:selectedPlaceAnnotation];
      }
  }
  
  - (BOOL)searchBarShouldBeginEditing:(UISearchBar *)searchBar {
      if (shouldBeginEditing) {
          // Animate in the table view.
          NSTimeInterval animationDuration = 0.3;
          [UIView beginAnimations:nil context:NULL];
          [UIView setAnimationDuration:animationDuration];
          // self.searchController.searchResultsTableView.alpha = 0.75;
          [(UITableViewController *)self.searchController.searchResultsController tableView].alpha = 0.75;
          [UIView commitAnimations];
  
          [self.searchController.searchBar setShowsCancelButton:YES animated:YES];
      }
      BOOL boolToReturn = shouldBeginEditing;
      shouldBeginEditing = YES;
      return boolToReturn;
  }
  
  - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
      return [searchResultPlaces count];
  }
  
  - (SPGooglePlacesAutocompletePlace *)placeAtIndexPath:(NSIndexPath *)indexPath {
      return searchResultPlaces[indexPath.row];
  }
  
  - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  
      static NSString *cellIdentifier = @"SPGooglePlacesAutocompleteCell";
      UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
      if (!cell) {
          cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
      }
  
      cell.textLabel.font = [UIFont fontWithName:@"GillSans" size:16.0];
      cell.textLabel.text = [self placeAtIndexPath:indexPath].name;
      return cell;
  }
  
  
  #pragma mark -
  #pragma mark UITableViewDelegate
  
  - (void)recenterMapToPlacemark:(CLPlacemark *)placemark {
      MKCoordinateRegion region;
      MKCoordinateSpan span;
  
      span.latitudeDelta = 0.02;
      span.longitudeDelta = 0.02;
  
      region.span = span;
      region.center = placemark.location.coordinate;
  
      [self.mapView setRegion:region];
  }
  
  - (void)addPlacemarkAnnotationToMap:(CLPlacemark *)placemark addressString:(NSString *)address {
      [self.mapView removeAnnotation:selectedPlaceAnnotation];
  
      selectedPlaceAnnotation = [[MKPointAnnotation alloc] init];
      selectedPlaceAnnotation.coordinate = placemark.location.coordinate;
      selectedPlaceAnnotation.title = address;
      [self.mapView addAnnotation:selectedPlaceAnnotation];
  }
  
  
  - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  
      SPGooglePlacesAutocompletePlace *place = [self placeAtIndexPath:indexPath];
      [place resolveToPlacemark:^(CLPlacemark *placemark, NSString *addressString, NSError *error) {
          if (error) {
              UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Could not map selected Place"
                                                              message:error.localizedDescription
                                                             delegate:nil
                                                    cancelButtonTitle:@"OK"
                                                    otherButtonTitles:nil, nil];
              [alert show];
          } else if (placemark) {
              [self addPlacemarkAnnotationToMap:placemark addressString:addressString];
              [self recenterMapToPlacemark:placemark];
              [self requestForwardGeoCoding:[self placeAtIndexPath:indexPath].name];
              // ref: https://github.com/chenyuan/SPGooglePlacesAutocomplete/issues/10
              [self.searchController setActive:NO];
              // [self.searchController.searchResultsTableView deselectRowAtIndexPath:indexPath animated:NO];
          }
      }];
  
  
  
  }
  
  @end
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/aF3FV.png" alt="My Error in attempt to convert to UISearchController"></p>
  
  <p><img src="https://i.stack.imgur.com/E5fi2.png" alt="App screenshot with no results predictions from google places api"></p>