1

我正在实现 twitter 应用程序,例如 #Discover 选项卡的动画。当用户点击搜索栏时,导航栏消失,tableView 电影向上,取消按钮显示在搜索栏上。这是代码...

- (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;
}

这非常有效,但仅在我第一次点击搜索栏时才需要大约半秒的延迟,之后它的速度很快。有任何想法吗?

4

1 回答 1

1

我认为如果您使用 UISearchDisplayController,您正在寻找或尝试编码的动画可以自动完成。UISearchDisplayController 一般用于显示结果。

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

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

self.tableView.tableHeaderView = searchBar_;
于 2012-03-06T13:51:01.880 回答