我有一个应用程序可以在 13,000 个单元格中搜索文本。我知道这是很多细胞。在较旧的 iphone 上,搜索需要几秒钟,所以我想提供一个指示器视图,向用户显示应用程序仍在工作。我想出了将 UISearchBar 放大镜更改为 UIActivityIndicatorView 的想法。该代码在模拟器中工作,但当我在旧的 ipod touch 上测试时,微调器没有出现。它实际上确实出现了,但只有在搜索完成后才会出现。知道为什么吗?这是代码。
- (void)searchBarTextDidEndEditing:(UISearchBar *)searchBar
{
UIActivityIndicatorView *spin = [[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
CGRect spinnerFrame = CGRectMake(12.0, 12.0, 20.0, 20.0);
spin.frame = spinnerFrame;
spin.clipsToBounds = YES;
spin.backgroundColor = [UIColor whiteColor];
[searchBar addSubview:spin];
[spin startAnimating];
[self performSelectorOnMainThread:@selector(filterContentForSearchText:) withObject:searchBar.text waitUntilDone:YES];
[spin stopAnimating];
[spin removeFromSuperview];
//[self filterContentForSearchText:searchBar.text];
[self.searchDisplayController.searchContentsController.navigationController setNavigationBarHidden:NO animated:YES];
[self.searchDisplayController.searchResultsTableView reloadData];
}