title: UISearchController & UISearchBar Subclass
body: <p>Aloha.</p>
  
  <p>I am having trouble getting a custom subclass of UISearchController, VLSearchController, with a custom UISearch Bar to call any of its delegate methods in my UIViewController. My custom subclasses don't have any delegate methods of their own, but I thought that since they were subclasses... their delegate methods would be subclassed as well and need to be defined inside of the UIViewController that initializes the UISearchController.</p>
  
  <p>After initializing the UISearchController, I set its delegate and the searchbar's delegate to the UIViewController:</p>
  
  <pre><code>_searchController = [[VLSearchController alloc] initWithSearchResultsController:nil];
  self.searchController.searchBar.delegate = self; 
  self.searchController.delegate = self;
  </code></pre>
  
  <p>The following delegate methods in my UIViewController don't get called:</p>
  
  <pre><code>#pragma mark - UISearchBarDelegate
  - (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar;
  
  #pragma mark - UISearchController
  - (void)willPresentSearchController:(UISearchController *)searchController;
  
  #pragma mark - UISearchResultsUpdating
  - (void)updateSearchResultsForSearchController:(UISearchController *)searchController;
  </code></pre>
  
  <p>Let me also mention that the reason that I subclassed the UISearchController as well as the UISearchBar was to get rid of the cancel button.
  Do I need to add delegate methods to the subclasses? If so, would anybody mind explaining what these delegate methods would do?</p>
  
  <p>EDIT: Addition of Code</p>
  
  <p>UIViewController:</p>
  
  <pre><code>-(void) viewDidLoad
  {
  
      [super viewDidLoad];
  
      //// Search &amp; Results Stuff
      _searchController = [[VLSearchController alloc] initWithSearchResultsController:nil];
      self.searchController.searchResultsUpdater = self;
  
      [self.searchController.searchBar sizeToFit];
      self.searchController.searchBar.barTintColor = UIColorFromRGB(0x411229);
  
      [self.sfView addSubview:self.searchController.searchBar];
  
      self.searchController.delegate  = self;
      self.searchController.dimsBackgroundDuringPresentation = NO;
      self.searchController.searchBar.delegate = self;
      self.definesPresentationContext = YES;
  } 
  
  - (void)viewDidAppear:(BOOL)animated 
  {
  
      [super viewDidAppear:animated];
  
      if (self.searchControllerWasActive) {
          self.searchController.active = self.searchControllerWasActive;
          _searchControllerWasActive = NO;
  
          if (self.searchControllerSearchFieldWasFirstResponder) {
              [self.searchController.searchBar becomeFirstResponder];
              _searchControllerSearchFieldWasFirstResponder = NO;
          }
      }
  }
  
  #pragma mark - UISearchBarDelegate
  
  - (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar 
  {
      [searchBar resignFirstResponder];
  }
  
  #pragma mark - UISearchController
  - (void)willPresentSearchController:(UISearchController *)searchController 
  {
      self.searchController.hidesNavigationBarDuringPresentation = false; // stop from animating
      [self.navigationController setNavigationBarHidden:NO animated:YES];
      self.searchController.searchBar.showsCancelButton = false;
  }
  
  - (void)didDismissSearchController:(UISearchController *)searchController{
      filteredPics=_pics;
  }
  
  #pragma mark - UISearchResultsUpdating
  
  - (void)updateSearchResultsForSearchController:(UISearchController *)searchController {};
  </code></pre>
  
  <p>VLSearchController</p>
  
  <pre><code>@interface VLSearchController () 
  @end
  
  @implementation VLSearchController{
      UISearchBar *_searchBar;
  }
  
  - (void)viewDidLoad {
      [super viewDidLoad];
      // Do any additional setup after loading the view.
  }
  
  -(UISearchBar *)searchBar 
  {
  
      if (_searchBar == nil) {
          _searchBar = [[VLSearchBar alloc] initWithFrame:CGRectZero];
      }
      return _searchBar;
  }
  
     -(void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText 
  {
          if ([searchBar.text length] &gt; 0) {
              self.active = true;
          } else {
              self.active = false;
          }
      }
  @end
  </code></pre>
  
  <p>VLSearchBar</p>
  
  <pre><code>@implementation VLSearchBar
  
  -(void)setShowsCancelButton:(BOOL)showsCancelButton {
      // Do nothing...
  }
  
  -(void)setShowsCancelButton:(BOOL)showsCancelButton animated:(BOOL)animated {
      // Do nothing....
  }
  
  @end
  </code></pre>