关于UISearchController的使用方法
2016-03-07 17:27
471 查看
首先头文件要引用UISearchBarDelegate
设置属性@property (nonatomic,strong)UISearchController * searchController;
在viewload里面设置:
self.searchController = [[UISearchController alloc] initWithSearchResultsController:nil];//初始化
[self.searchController.searchBar sizeToFit];//自动适应大小
self.tableView.tableHeaderView = self.searchController.searchBar;//tableview的头视图就是searchBar
self.searchController.dimsBackgroundDuringPresentation = YES;
self.searchController.hidesNavigationBarDuringPresentation = NO;
self.searchController.searchBar.delegate = self;
方法:
- (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar{
//点击搜索后调用的方法
代码不全,一般这里要调用接口,用srVC的数组接收数据,再转过去到srVC
SearchResultViewController * srVC = [[SearchResultViewController alloc] init];
srVC.searchText = searchBar.text;
[self.navigationController pushViewController:srVC animated:YES];
}
设置属性@property (nonatomic,strong)UISearchController * searchController;
在viewload里面设置:
self.searchController = [[UISearchController alloc] initWithSearchResultsController:nil];//初始化
[self.searchController.searchBar sizeToFit];//自动适应大小
self.tableView.tableHeaderView = self.searchController.searchBar;//tableview的头视图就是searchBar
self.searchController.dimsBackgroundDuringPresentation = YES;
self.searchController.hidesNavigationBarDuringPresentation = NO;
self.searchController.searchBar.delegate = self;
方法:
- (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar{
//点击搜索后调用的方法
代码不全,一般这里要调用接口,用srVC的数组接收数据,再转过去到srVC
SearchResultViewController * srVC = [[SearchResultViewController alloc] init];
srVC.searchText = searchBar.text;
[self.navigationController pushViewController:srVC animated:YES];
}
相关文章推荐
- iOS开发——UISearchController实现搜索栏功能|阳和移动开发
- object-c之UITableView的数据索引控件UISearchController
- object-c之UITableView的数据索引控件UISearchController
- UISearchController进行网络实时搜索
- UISearchController的简单用法
- UISearchController
- iOS8 UISearchViewController搜索功能讲解
- 系统自带的搜索控制器和自己封装的带搜索记录的控制器
- iOS开发之高级视图—— UISearchController
- 搜索框UISearchController的使用及所遇到的坑
- UISearchController搜索框偏移问题 - 芒果iOS开发
- UISearchController自动弹出键盘,调用becomeFirstResponder变为第一响应事件
- IOS UISearchController的简单开发实现(swift版)
- UISearchController搜索框禁止向上移动
- UISearchController的obscuresBackgroundDuringPresentation属性不支持iOS8的问题
- UISearchController偏移
- UISearchController
- iOS UISearchController的使用方法
- iOS开发之UITableView与UISearchController实现搜索及上拉加载,下拉刷新实例代码
- iOS中Swift UISearchController仿微信搜索框