用UISearchBar初始化,设置代理
UISearchBar *searchBar = [[UISearchBar alloc] init];
self.tableView.tableHeaderView = searchBar;
[searchBar sizeToFit];
searchBar.delegate = self;
[searchBar release];
searchDisplay = [[UISearchDisplayController alloc] initWithSearchBar:searchBar contentsController:self];
searchDisplay.delegate = self;
searchDisplay.searchResultsDataSource = self;
searchDisplay.searchResultsDelegate = self;
检测当前table view,分情况选择需要显示的数据
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
if ([tableView isEqual:self.searchDisplayController.searchResultsTableView]) {
return self.searchGroupList.count;
}
return [self.groupList count];
}
cellForRowAtIndexPath同样选择
实现
- (BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString;
用于重新填充搜索出的数据
分享到:
相关推荐
系统自带搜索UISearchDisplayController
TabBar+Table+UISearchDisplayController,页面跳转,搜索等应用;
使用UISearchDisplayController显示搜索结果博客对应的Demo。 原文地址:http://blog.csdn.net/jymn_chen/article/details/24608097
在UINavigationBar上显示UISearchBar, 并实现UISearchDisplayController功能的小Demo, 更多讲解在http://www.cnblogs.com/sely-ios/p/Sely.html
UISearchDisplayController搜索.rar
ios UISearchDisplayController 实现 UITableView 搜索功能 - LeslieFang - 博客园1
因为系统的UISearchDisplayController用起来各种坑,实在是累觉不爱,没办法只好自己写一个searchView,用法和UISearchDisplayController基本相同,代理方法可以自己添加,我就只写了一个。
IOS应用源码——UISearchDisplayController(搜索).zip
IOS应用源码——UISearchDisplayController(搜索).rar
IOS应用源码——TabBar+Table+UISearchDisplayController.rar
iOS8.0后UISearchController取代了UISearchDisplayController,这里对UISearchController的一些基本用法做了一个小Demo.
演示如何使用 NSFetchedResultsController 实现 UISearchDisplayController 来过滤核心数据对象 ##要求 Xcode 6 iOS 7.0+ ##例子 ##Credits CoreDataSearchBarDemo 由创建 ##License ######MIT 许可证 (MIT)...
UISearchController 内部自带 searchBar 等价于 UISearchDisplayController + UISearchBar
UISearchDisplayController适配 ##Description 本Demo的搜索栏UISearchBar脱离UITableView的tableHeaderView而存在,做了对iOS7,8的适配 ##效果图 ##测试环境 Xcode 6.4,模拟器iPhone5,5s,6,6 plus,真机5 iOS8.1
主要介绍了iOS应用中UISearchDisplayController搜索效果的用法,包括点击搜索出现黑条问题的解决方法,代码基于传统的Objective-C,需要的朋友可以参考下
原始示例使用 UISearchDisplayController,它在 iOS 8 中已弃用。 每个选项卡都使用 UISearchController 以不同的方式显示搜索结果: 在表格视图中,非常类似于使用 UISearchDisplayController 在集合视图中 ...
RoySearch//把UISearchBar和UISearchDisplayController封装在一起的一个Search控件,用时只需在需要调用的ViewController里调用即可。完美适配tableView。//A customed and packaged category that combined ...
通过 fmdb 进行的数据库的 基本操作(增删改查 )查找是使用 UISearchBar 和UISearchDisplayController 进行混合使用