2
我有一個應用程序,通過13,000個單元格搜索文本。我知道這是很多細胞。在較舊的iPhone上,搜索需要幾秒鐘的時間,因此我想提供一個指示器視圖,向用戶顯示該應用程序仍在工作。我想出了將UISearchBar放大鏡更改爲UIActivityIndicatorView的想法。該代碼在模擬器中工作,但是當我在舊的iPod touch上測試時,微調框不顯示。它實際上確實顯示,但只有在搜索完成後才顯示。任何想法爲什麼?這是代碼。更改搜索放大鏡到UIActivityIndicatorView
- (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];
}