title: How can I get the searchBarDelegate methods with a custom UISearchBar?
body: <p>I made a custom search bar for my app, here is the class:
  .h</p>
  
  <pre><code>@interface SearchView : UIView &lt;UITextFieldDelegate, UISearchBarDelegate&gt;
  @property (nonatomic, strong) UITextField *searchField;
  @property (nonatomic, strong) UIButton *searchButton;
  @end
  </code></pre>
  
  <p>.m</p>
  
  <pre><code>@implementation SearchView
  
  - (id)initWithFrame:(CGRect)frame
  {
      self = [super initWithFrame:frame];
      if (self) {
  
        CGRect frame = CGRectMake(0, 0, 35, 35);
  
        [self.searchButton sizeToFit];
        self.alpha = 0.6;
        self.backgroundColor = [UIColor colorWithRed:206/255.0 green:206/255.0 blue:206/255.0 alpha:.8];
        self.searchButton = [UIButton buttonWithType:UIButtonTypeCustom];
        //[self.searchButton addTarget:self action:@selector(performSearchQuery) forControlEvents:UIControlEventTouchUpInside];
        [self.searchButton setImage:[UIImage imageNamed:@"SearchIcon2"] forState:UIControlStateNormal];
        //[self.searchButton sizeToFit];
        //self.searchButton.bounds.size.height = ;
        self.searchButton.frame = frame;
       // self.searchButton.right = frame.size.width - kPadding;
        [self addSubview:self.searchButton];
  
        self.searchField = [[UITextField alloc] initWithFrame:CGRectMake(43, -5, 270, 50)];
        //self.searchField.placeholder = [@"Search..." uppercaseString];
        self.searchField.delegate = self;
        self.searchField.autocorrectionType = UITextAutocorrectionTypeNo;
        self.searchField.autocapitalizationType = UITextAutocapitalizationTypeWords;
        self.searchField.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
        self.searchField.returnKeyType = UIReturnKeySearch;
        self.searchField.clearsOnBeginEditing = YES;
        self.searchField.clearButtonMode = UITextFieldViewModeWhileEditing;
        [self addSubview:self.searchField];
  
      }
      return self;
  }
  </code></pre>
  
  <p>I'm trying to get the functionality of the <code>searchBarSearchButtonClicked:</code> delegate method.</p>
  
  <p>Here is the code for that (taskListViewController):</p>
  
  <p>.h</p>
  
  <pre><code>@interface TaskListViewController : UIViewController &lt;UITableViewDelegate,UITableViewDataSource, UISearchBarDelegate, UITextFieldDelegate, ScavengerAPIGetTaskListDelegate&gt;{
      SearchView *searchView;
  }
  </code></pre>
  
  <p>.m</p>
  
  <pre><code>- (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar {
    searchBar = (UISearchBar *)searchView;
  
    [self didTapSearchButton];
  }
  
  - (IBAction)didTapSearchButton
  
      {
        NSString *searchTerm = searchView.searchField.text;
  
        if ([searchTerm isEqualToString:@""]) {
          [self.view endEditing:YES];
          return ;
        }
  
        [searchView resignFirstResponder];
        NSArray *results = [[CoreDataManager sharedInstance] fetchTaskByName:searchTerm];
  
        [tasks removeAllObjects];
        [tasks addObjectsFromArray:results];
  
        [self.view endEditing:YES];
        [taskTable reloadData];
      }
  </code></pre>
  
  <p>So i set up the uisearchBarDelegate on both the searchView class and TaskListViewController. Is the reason it is not getting called because I am subclassing uiview instead of uisearchBar? If you need more code/details, let me know! Thanks!</p>