title: Use custom UISearchBar with UISearchController
body: <p>I want to use a custom UISearchBar with the UISearchController as navigation title to work around the issue with iOS 11 that the height changed from 44 to 56 points. But I fail to understand how I can set the custom search bar to the search controller - the searchbar property is read-only. All my searches on the topic didn't result in anthing that helps me get on the right path.</p>
  
  <p>Here is my search controller code:</p>
  
  <p><em>Note: AppSearchControllerViewController is a simple UITableViewController displaying the results via an NSMutableArray</em></p>
  
  <p><em>Note 2: the view controller implements the delegate "UISearchBarDelegate"</em></p>
  
  <pre><code>-(void)viewDidLoad {
      searchResultsController = [[AppSearchControllerViewController alloc] init];
      appSearchController = [[UISearchController alloc] initWithSearchResultsController:searchResultsController];
      [searchResultsController setParentNavigationController:self.navigationController];
      appSearchController.searchResultsUpdater = self;
      appSearchController.dimsBackgroundDuringPresentation = YES;
      // Usually one would set up the searchbar like this
      //  self.navigationItem.titleView = appSearchController.searchBar;
      // but instead I do this:
      [self addSearchBar];
  }
  
  - (void)addSearchBar {
      _searchBar = [self addSearchBarWithFrame:CGRectMake(0, 0, kScreenWidth - 2 * 44 - 2 * 15, 44)];
      UIView *wrapView = [[UIView alloc] initWithFrame:_searchBar.frame];
      [wrapView addSubview:_searchBar];
      self.navigationItem.titleView = wrapView;
  }
  
  - (WMSearchBar *)addSearchBarWithFrame:(CGRect)frame {
      self.definesPresentationContext = YES;
      WMSearchBar *searchBar = [[WMSearchBar alloc]initWithFrame:frame];
      searchBar.delegate = self;
      searchBar.placeholder = [Language get:@"APP_SEARCH_NAVBAR_TEXTFIELD_SEARCH_PLACEHOLDER"];
      [searchBar setShowsCancelButton:NO];
      [searchBar setTintColor:KGenericColor];
  
      if (self.isChangeSearchBarFrame) {
          CGFloat height = searchBar.bounds.size.height;
          CGFloat top = (height - 20.0) / 2.0;
          CGFloat bottom = top;
          searchBar.contentInset = UIEdgeInsetsMake(top, 0, bottom, 0);
      }
      return searchBar;
  }
  </code></pre>
  
  <p>WMSearchBar class is from this Github repo: <a href="https://github.com/DreamTravelingLight/searchBarDemo" rel="nofollow noreferrer">https://github.com/DreamTravelingLight/searchBarDemo</a></p>
  
  <p>This make the search bar perfectly fit again to 44 points and also do the fade in/out animation on controller transitions.</p>
  
  <p>The issue is now, that I receive all the events from the search bar - that all works. But the search results controller is not triggered so the results also don't display.</p>
  
  <p>I tried also to set the original search bar's text from my custom new search bar, but same effect - results controller does not show up. What do I need to do to wire in the new search bar and replace the old one?</p>
  
  <pre><code>- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText {
      NSLog(@"textDidChange: %@", searchText);
      appSearchController.searchBar.text = searchText;
      ...
  </code></pre>