【发布时间】:2015-03-10 22:38:10
【问题描述】:
您好,我创建了一个 UISearchController 来在我的应用程序中搜索 tableview,因为我知道 UISearchDisplay Controller 方法在 iOS 8 中已被弃用,现在在 8.1 模拟器中一切正常,当我尝试运行我的应用程序时在 iOS 7.1 版本的 iPad 中,我发现搜索栏不见了,所以请帮助我如何创建一个搜索栏,它支持从 6.0 开始的所有 iOS 版本
- (void)updateSearchResultsForSearchController:(UISearchController *)searchController {
UISearchBar *searchBar = searchController.searchBar;
if (searchBar.text.length > 0) {
NSString *text = searchBar.text;
NSPredicate *predicate = [NSPredicate predicateWithBlock:^BOOL(NSString *play, NSDictionary *dict) {
NSRange range = [play rangeOfString:text options:NSCaseInsensitiveSearch];
return range.location != NSNotFound;
}];
NSArray *searchResults = [self.dataARR filteredArrayUsingPredicate:predicate];
【问题讨论】:
标签: ios uisearchbar uisearchdisplaycontroller uisearchcontroller uisearchbardisplaycontrol