UISearchBar和UISearchDisplayController
来源:互联网 发布:零基础程序员入门书籍 编辑:程序博客网 时间:2024/05/17 06:53
UISearchBar继承自UIView、UIResponder、NSObject
UISearchBar不执行搜索行为,必须使用delegate,当输入搜索文本、点击button按钮后,代理的方法会完成搜索对应的操作。
1.编辑输入事件:
–
searchBar:textDidChange: –
searchBar:shouldChangeTextInRange:replacementText: –
searchBarShouldBeginEdit ing: –
searchBarTextDidBeginEdi ting: –
searchBarShouldEndEditin g: –
searchBarTextDidEndEditi ng:
2.点击按钮事件:
–
searchBarBookmarkButtonC licked: –
searchBarCancelButtonCli cked: –
searchBarSearchButtonCli cked: –
searchBarResultsListButt onClicked:
3.Scope按钮事件:
–
searchBar:selectedScopeButtonIndex DidChange:
利用UISearchBar的委托事件
利用UISearchDisplayControlle
属性:
active————是搜索界面可视化,默认为no,可用setActive方法设置.
delegate————委托
searchBar————在searchdisplaycontroller初始化后,searchbar是不可修改的,是readonly属性的.
searchContentController————管理搜索内容的试图控制器,一般是一个UITableViewController的实例,意思是针对一个UITableView的内容进行搜索
searchResultsDataSource————搜索结果的数据源
searchResultsDelegate————搜索结果的委托
searchResultsTableView————搜索结果要展示在哪个tableview中(read-only);
searchResultsTitle————搜索结果视图的title
初始化一个searchDisplayController:
使用UISearchDisplayDelegate的委托方法进行搜索操作:
1.搜索状态改变:
–
searchDisplayControllerW illBeginSearch: –
searchDisplayControllerD idBeginSearch: –
searchDisplayControllerW illEndSearch: –
searchDisplayControllerD idEndSearch:
2.装载和卸载tableview:
–
searchDisplayController:didLoadSearchResultsTabl eView: –
searchDisplayController:willUnloadSearchResultsT ableView:
3.显示和隐藏tableview:
–
searchDisplayController:willShowSearchResultsTab leView: –
searchDisplayController:didShowSearchResultsTabl eView: –
searchDisplayController:willHideSearchResultsTab leView: –
searchDisplayController:didHideSearchResultsTabl eView:
4.搜索条件改变时响应:
–
searchDisplayController:shouldReloadTableForSear chString: –
searchDisplayController:shouldReloadTableForSear chScope:
searchDisplayController 自身有一个searchResultsTableView,所以在执行操作的时候首先要判断是否是搜索结果的tableView,如果是显示的就是搜索结 果的数据,如果不是,是TableView自身的view,则需要显示原始数据。
这样就不需要每次都realoadData了。
- UISearchBar和UISearchDisplayController
- UISearchBar和UISearchDisplayController
- UISearchBar和UISearchDisplayController
- UISearchBar和UISearchDisplayController
- UISearchBar和UISearchDisplayController
- UISearchBar和UISearchDisplayController
- UISearchBar和UISearchDisplayController
- UISearchBar和UISearchDisplayController
- UISearchBar和UISearchDisplayController
- UISearchBar和UISearchDisplayController
- UISearchDisplayController 和 UISearchBar
- UISearchBar和UISearchDisplayController
- UISearchBar和UISearchDisplayController
- UISearchBar 和 UISearchDisplayController
- UISearchBar和UISearchDisplayController
- UISearchDisplayController和UISearchBar
- 自定义UISearchBar和UISearchDisplayController
- iOS UISearchBar和UISearchDisplayController
- oracle一条语句递归查询父子关系
- 杭电1575-Tr A(矩阵快速幂)
- C/C++中的内存分区及堆栈相关知识
- 写给浮躁的IT同仁
- jdk安装篇
- UISearchBar和UISearchDisplayController
- 我心目中的编程高手(完整版)
- IOS数组按中文关键字以字母序排序
- 中国鹰派联盟网主题歌《黑夜的力量》
- wpf控件2
- (转贴)大教堂和市集
- 流程图和其他常用图表介绍
- C语言中的typeof关键字
- 《专业主义》阅读摘要——作者:大前研一