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 系统可能会移除 ...
随机推荐
- SQL Server :理解Page Free Space (PFS) 页
原文:SQL Server :理解Page Free Space (PFS) 页 我们已经讨论了GAM与SGAM页,数据页(Data Page) ,现在我们来看下页面自由空间页(Page Free S ...
- Java并发学习之中的一个——线程的创建
本文是学习网络上的文章时的总结,感谢大家无私的分享. 1.与每一个Java语言中的元素一样,线程是对象.在Java中,我们有两种方式创建线程: a.通过直接继承thread类,然后覆盖run方法. b ...
- uva live 4394 String painter 间隔dp
// uva live 4394 String painter // // 问题是,在培训指导dp运动主题,乍一看,我以为只是一点点复杂 // A A磕磕磕,两个半小时后,.发现超过例子.然而,鉴于他 ...
- Linux 编程学习笔记----ANSI C 文件I/O管理
转载请注明出处:http://blog.csdn.net/suool/article/details/38129201 问题引入 文件的种类 依据数据存储的方式不同,能够将文件分为文本文件和二进制文件 ...
- IIS6,IIS7中查看w3wp进程
当我们服务器创建了很多应用程序池,然后某个w3wp.exe进程占用CPU和内存过高,我们怎么查找这个w3wp.exe进程属于哪一个网站呢.其实微软为我们提供了很好的查看工具: 首先打开windows任 ...
- 【Android先进】查看手机记忆库状态和应用方法
一世 我们知道.android程序存储器通常被限制16M.当然,24M的,和android程序存储器分为2部分:native和dalvik.dalvik 就是我们寻常说的java堆.我们创建的对象是在 ...
- [Windows Phone] 以多国语言做为开发前提 (2)
原文:[Windows Phone] 以多国语言做为开发前提 (2) ? 前言 在先前的文章 [Windows Phone 开发 - 以多国语言做为开发前提 (1)] 中说明了简单的多国语言范例,今天 ...
- 查看linux系统版本号命令
一.查看内核版本号命令: 1) [root@SOR_SYS ~]# cat /proc/version Linux version 2.6.18-238.el5 (mockbuild@x86-012. ...
- 乐在其中设计模式(C#) - 适配器模式(Adapter Pattern)
原文:乐在其中设计模式(C#) - 适配器模式(Adapter Pattern) [索引页][源码下载] 乐在其中设计模式(C#) - 适配器模式(Adapter Pattern) 作者:webabc ...
- Andorid Async-HttpClient阅览
Async-httpclient它是一个用于Android应用程序开发http访问开源框架.开源GitHub在,因为今天GitHub下载没有看到.我在这里提供下载地址.是之前从GitHub上下载的,版 ...