title: App crashes when clicking on UISearchbar (searchDisplayController)
body: <p>I am implementing the searchdisplay controller on the iPhone App, but will hit the following error when I try to click on the search bar (after a few tries)</p>
  
  <pre><code>Thread 1: EXC_BAD_ACCESS (code=1, address=0x30000008)
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/lVq4v.png" alt="enter image description here"></p>
  
  <p>Snippet of my code as follows:</p>
  
  <pre><code>- (void)viewDidLoad
  {
  
    //Setting up the search bar for search display controller
    UISearchBar *tempBar = [[UISearchBar alloc]initWithFrame:CGRectMake(0, 34, 320, 44)];
    self.sBar = tempBar;
    [tempBar release];
    self.sBar.delegate = self;
    self.sBar.tintColor = [UIColor colorWithHexString:@"#b6c0c7"];
    self.sBar.placeholder = @"Search DM friends";
  
    self.searchDisplayController = [[[UISearchDisplayController alloc] initWithSearchBar:sBar contentsController:self]autorelease];
    [self setSearchDisplayController:searchDisplayController];
    [searchDisplayController setDelegate:self];
    [searchDisplayController setSearchResultsDataSource:self];
    self.searchDisplayController.searchResultsTableView.delegate = self;
  }
  
  
  - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
  {
      UIView *headerView = [[[UIView alloc]initWithFrame:CGRectMake(0, 0, 320, 78)]autorelease];
      headerView.backgroundColor = [UIColor colorWithHexString:@"#ebe7e6"];
  
      if (tableView != self.searchDisplayController.searchResultsTableView){
          //Search
  
          UILabel *tagFriendsTitle = [[UILabel alloc]initWithFrame:CGRectMake(10, 10, 320, 16)];
          tagFriendsTitle.font = [UIFont boldSystemFontOfSize:14];
          tagFriendsTitle.backgroundColor = [UIColor clearColor];
          tagFriendsTitle.text = @"Who should see this? Tag them!";
  
          [headerView addSubview:tagFriendsTitle];
  
          //THIS IS WHERE I GET MY EXC_BAD_ACCESS error
          [headerView addSubview:self.sBar];
  
          [tagFriendsTitle release];
  
      }
      return headerView;
  
  }
  </code></pre>
  
  <p>I am not sure which part of my code is causing the error, but it seems that the sBar deallocated from memory when I try to add it to header subview? But I am not sure why I needed to click on the search bar multiple times before that happens.</p>
  
  <p>This is how it looks on the iPhone, the searchbar forms part of the headerview</p>
  
  <p><img src="https://i.stack.imgur.com/NMojj.png" alt="enter image description here"></p>