iOS UISearchDisplayController学习笔记
UISearchDisplayController和UISearchBar一起使用用来管理UISearchBar和搜索结果的展示。UISearchDisplayController提供了显示搜索结果的tableview来覆盖原控制器的视图;
使用UISearchDisplayController须要:
- 提供搜索结果table的数据的来源-searchResultsDataSource
- 搜索结果table的代理 SearchResultsDelegate
- UISearchDisplayController控制器的代理delegate ,对应搜索事件的開始结束和显示隐藏界面;(这个代理知道搜索字符串的改变和搜索范围,所以结果table可以(自己主动)又一次导入)
- searchBar的代理(关于UISearchBar代理上篇文章已经说明)
一般是在在uitableview中初始化UISearchDisplayController来展示一个列表。
searchController = [[UISearchDisplayController alloc]
initWithSearchBar:searchBar contentsController:self];
searchController.delegate = self;
searchController.searchResultsDataSource = self;
searchController.searchResultsDelegate = self;
在tabelview代理方法中须要推断是哪一个table(UITableViewController中有self.tableView UISearchDisplayController中有.searchResultsTableView)
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
if (tableView == self.tableView) {
return ...;
}
// If necessary (if self is the data source for other table views),
// check whether tableView is searchController.searchResultsTableView.
return ...;
}
一个UIViewController和一个UISearchBar仅仅有一个UISearchDisplayController。
你可以在ios7 之后,在navigationbar中使用SearchDisplayController,通过配置UISearchDisplayController中得displaysSearchBarInNavigationBar和
navigationItem属性;
相关的属性和方法
@property(nonatomic, getter=isActive) BOOL active
展现(是否隐藏)状态。默认值是NO。直接设置没有动画,用setActive:animated: 设置会有动画
@property(nonatomic,
assign) id<UISearchDisplayDelegate>
delegate
代理
@property(nonatomic,
assign) BOOL displaysSearchBarInNavigationBar
指定navigationbar中包括一个searchBar
@property(nonatomic,
readonly) UINavigationItem *navigationItem
仅仅读属性 代表在navigation controller的navigationbar中的searchdisplaycontroller;
@property(nonatomic, readonly) UISearchBar *searchBar
UISearchDisplayController中的UISearchBar;
@property(nonatomic,
readonly) UIViewController *searchContentsController
这个属性管理着搜索出的内容
@property(nonatomic,
assign) id<UITableViewDataSource>
searchResultsDataSource
展示搜索结果的数据来源
@property(nonatomic,
assign) id<UITableViewDelegate>
searchResultsDelegate
搜索结果展示的table的代理
@property(nonatomic,
readonly) UITableView *searchResultsTableView
搜索结果展示的table
@property(nonatomic,
copy) NSString *searchResultsTitle
搜索结果视图的标题
-
(id)initWithSearchBar:(UISearchBar *)searchBar contentsController:(UIViewController *)viewController
初始化控制器
指定关联的search 和view controller
- (void)setActive:(BOOL)visible animated:(BOOL)animated
展现或者隐藏搜索视图
内容来自苹果文档
iOS UISearchDisplayController学习笔记的更多相关文章
- iOS音频学习笔记二:iOS SDK中与音频有关的相关框架
上层: Media Player Framework: 包含MPMoviePlayerController.MPMoviePlayerViewController.MPMusicPla ...
- iOS音频学习笔记一:常见音频封装格式及编码格式
(1) pcm格式 pcm是经过话筒录音后直接得到的未经压缩的数据流 数据大小=采样频率*采样位数*声道*秒数/8 采样频率一般是22k或者44k,位数一般是8位或者16位,声道一 ...
- iOS开发学习笔记:基础篇
iOS开发需要一台Mac电脑.Xcode以及iOS SDK.因为苹果设备都具有自己封闭的环境,所以iOS程序的开发必须在Mac设备上完成(当然,黑苹果应该也是可以的,但就需要花很多的精力去折腾基础环境 ...
- iOS开发学习笔记
1 常用的第三方工具 1.1 iPhone Simulator 测试程序需要模拟器iPhone Simulator 1.2 设计界面需要Interface Builder,Interface Buil ...
- iOS - CAEmitterLayer 学习笔记一
其他参考博客: http://my.oschina.net/u/2340880/blog/485095 http://www.cnblogs.com/YouXianMing/p/3785876.htm ...
- ios开发学习笔记(这里一定有你想要的东西,全部免费)
1,Search Bar 怎样去掉背景的颜色(storyboard里只能设置background颜色,可是发现clear Color无法使用). 其实在代码里还是可以设置的,那就是删除背景view [ ...
- iOS开发应用学习笔记
一.iOS应用设计 1. 参考资料: 解读iPhone平台的一些优秀设计思路 iPhone App的特点及基本设计方法 Mobile UI design and Developer 2. 用户对iPh ...
- ios 框架学习笔记
ios主要的系统层次: 一.Cocoa Touch 层:创建应用程序主要使用的框架. 1.关键技术: AirDrop:实现应用间通信. Text Kit:处理文本和排版. UIKit Dynamics ...
- ios 存储学习笔记
一.主要路径: Library/Caches/此文件用于存储那些需要及可延迟或重创建的临时数据.且这些内容不会被IOS 系统备份,特别地,当设备磁盘空间不足且应用不在运行状态时,IOS 系统可能会移除 ...
随机推荐
- paip.android环境搭建与开发事例
paip.android环境搭建与开发事例 好长时间没有玩AndROID了..以前常常做ANDROID的,今天决定在下载一个要做个时间设置器 作者Attilax , EMAIL:1466519819 ...
- 【原创】ZOJ_1649 Rescue 解题报告
Rescue Time Limit: 2 Seconds Memory Limit: 65536 KB Angel was caught by the MOLIGPY! He was put ...
- windows Azure平台开发
rest api 和SDK power shell azure pack
- Memcahce(MC)系列(两)Linux下一个Memcache安装
Linux下一个memcache安装 memcache是高性能.分布式的内存对象缓存系统,用于在动态应用中降低数据库负载.提升訪问速度.眼下用memcache解决互联网上的大用户读取是很流行的一种使用 ...
- jquery 判断当前上传文件大小限制上传格式 搭配thinkphp实现上传即预览(模拟异步上传)
在web开发中,最纠结的一项就是文件上传,最近由于项目需要前后摸索了四天在这里分享给大家.如有不足,望指出!! 前台:jquery.easyui.html 后台:thinkphp 主要涉及语言:jqu ...
- C#访问Java的WebService添加SOAPHeader验证的问题
原文:C#访问Java的WebService添加SOAPHeader验证的问题 这两天做与公司OA的接口,发现C#访问Java的WebService需要提供一个SOAP的头验证信息,但是WebServ ...
- 原来Github上的README.md文件这么有意思——Markdown语言详解
转载请注明出处:http://blog.csdn.net/zhaokaiqiang1992 之前一直在使用github,也在上面分享了不少的项目和Demo,每次创建新项目的时候,使用的都是默认的REA ...
- IBatis.Net获取执行的Sql语句
前言 IBatis.Net中Sql语句是些在配置文件中的,而且配置文件是在程序启动时读取的(我们开发的时候需要将其设置成较新复制或者是始终复制),而不是程序将其包含在其中(例如NHibernate的映 ...
- Windows 8实例教程系列 - 数据绑定高级实例
原文:Windows 8实例教程系列 - 数据绑定高级实例 上篇Windows 8实例教程系列 - 数据绑定基础实例中,介绍Windows 8应用开发数据绑定基础,其中包括一些简单的数据绑定控件的使用 ...
- Apache Commons Math3学习笔记(2) - 多项式曲线拟合(转)
多项式曲线拟合:org.apache.commons.math3.fitting.PolynomialCurveFitter类. 用法示例代码: // ... 创建并初始化输入数据: double[] ...