title: Implement Search Bar in iphone Mail app to shift up nav bar and search bar to reveal scope bar
body: <p>I would like to implement a search bar with the exact same behavior as the mail app on the iphone.  I cannot get the scopebar to reveal itself smoothly while the navigation bar and search bar are shifting upwards the way the mail program does it.  In the mail app the nav bar and search bar move up to reveal the scopebar.  How would i implement that kind of animation?</p>
  
  <p>I did something crude:</p>
  
  <pre><code>- (BOOL)searchBarShouldBeginEditing:(UISearchBar *)searchBar {
      searchBar.scopeButtonTitles = [NSArray arrayWithObjects:@"Button",@"Titles",@"Go",@"Here",nil];
      searchBar.showsScopeBar = YES;
      [searchBar setShowsCancelButton:YES animated:YES]; 
      [self.navigationController setNavigationBarHidden:YES animated:YES];
      self.tableView.contentOffset = CGPointMake(0, 0);
  
      [searchBar sizeToFit];
      return YES;
  }
  </code></pre>
  
  <p>the search bar is allocated in my viewdidload as follows:</p>
  
  <pre><code>UISearchBar *searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0, 0, 320, 44)];
      searchBar.delegate = self;
      self.tableView.tableHeaderView =searchBar;
      [searchBar release];
  </code></pre>
  
  <p>In my viewwillappear i offset the table view to hide the search bar under the nav bar:</p>
  
  <pre><code>- (void)viewWillAppear:(BOOL)animated {
      [super viewWillAppear:animated];
      self.tableView.contentOffset = CGPointMake(0, 44);
  
  }
  </code></pre>
  
  <p>Thanks!</p>