Reputation: 9555
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?
I did something crude:
- (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;
}
the search bar is allocated in my viewdidload as follows:
UISearchBar *searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0, 0, 320, 44)];
searchBar.delegate = self;
self.tableView.tableHeaderView =searchBar;
[searchBar release];
In my viewwillappear i offset the table view to hide the search bar under the nav bar:
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
self.tableView.contentOffset = CGPointMake(0, 44);
}
Thanks!
Upvotes: 0
Views: 1392
Reputation: 30846
Try sending -setNavigationBarHidden:animated:
to the navigation bar in - searchBarTextDidBeginEditing:
.
Upvotes: 0