Frage

I am implementing the twitter app like animation of the #Discover tab. When the user taps the searchbar, the navigationBar disappears, the tableView movies up and the cancel button shows up on the searhbar. Here's the code...

- (BOOL)searchBarShouldBeginEditing:(UISearchBar *)searchBar
{
    [self.navigationController setNavigationBarHidden:YES animated:YES]; 
    [self.searchBar setShowsCancelButton:YES animated:YES];
    [self.scrollView setContentOffset:CGPointMake(0, 55) animated:YES];
    [self.view addSubview:backImgView];
    return  YES;
}

This works perfectly, but it takes about half a second delay only the first time I tap the searchbar, After that its fast. Any Ideas?

War es hilfreich?

Lösung

I think the animation you are looking for or trying to code , can be done automatically if you use UISearchDisplayController. UISearchDisplayController is generally used to display results.

UISearchBar *searchBar_ = [[[UISearchBar alloc] initWithFrame:CGRectMake(0, 0, 320, 44)] autorelease]; 

UISearchDisplayController *searchDisplayController_ = [[UISearchDisplayController alloc] initWithSearchBar:searchBar_ contentsController:self] ; 

self.tableView.tableHeaderView = searchBar_;
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top