我的应用程序有大约200个UITableView行,当我在xcode上使用模拟器通过UISearchBar过滤数据时,它立即过滤并显示结果,但是,当我在我的iphone中运行我的应用程序(iphone4 ,iOS 5.1.1),它会在显示任何搜索结果之前挂起几秒钟。我使用这个代码过滤数据...SearchBar挂在iphone上,但在模拟器上工作正常
- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText{
[self.filteredData removeAllObjects];
if ([searchText length] > 0) {
self.isSearching = YES;
for (AClass *filteredData in self.allData) {
NSRange titleResultRange = [filteredData.name rangeOfString:self.searchBar.text options:NSCaseInsensitiveSearch];
if (titleResultRange.location != NSNotFound) {
[self.filteredData addObject:filteredData];
}
}
}
else self.isSearching = NO;
[self.tableView reloadData];}
我相信我的代码是好的,因为它的工作完全正常的模拟器,有什么我需要做,使之更快地适用于iPhone? 顺便说一句,我的iPhone工作正常,我使用其他应用程序,他们工作正常..
谢谢darkfoxmrd! – DevCali 2013-05-01 01:33:50