zoukankan      html  css  js  c++  java
  • UISearchController

    搜索框UISearchController的使用(iOS8.0以后替代UISearchBar + UIS)

    1.在iOS 8.0以上版本中, 我们可以使用UISearchController来非常方便地在UITableView中添加搜索框. 而在之前版本中, 我们还是必须使用UISearchBar + UISearchDisplayController的组合方式.

    2.在使用UISearchController前先定义以下属性

    //定义一个UISearchController
    @property (nonatomic,strong) UISearchController *searchController;
    //用来展示搜索结果
    @property (nonatomic,strong) ResultViewController *resultVC;
    //用来接收searchController搜索出来的结果
    @property (nonatomic,strong) NSMutableArray *searchArr;

    //开辟空间,用来接受搜索出来的结果 _searchArr = [[NSMutableArray alloc] init]; //实例化searchController _searchController = [[UISearchController alloc] initWithSearchResultsController:_resultVC]; //设置搜索更新时调用的代理 _searchController.searchResultsUpdater = self; //设置搜索框,自适应,否则搜索框无法显示 [_searchController.searchBar sizeToFit]; //将搜索框添加到tableView上 [_tableView addSubview:_searchController.searchBar]; //以下属性感觉设置跟没设置没啥差别 //设置开始搜索时背景显示与否 _searchController.dimsBackgroundDuringPresentation = NO; //搜索时,背景变暗色 _searchController.dimsBackgroundDuringPresentation = NO; //搜索时,背景变模糊 _searchController.obscuresBackgroundDuringPresentation = NO; //隐藏导航栏 _searchController.hidesNavigationBarDuringPresentation = NO;

      

  • 相关阅读:
    python 回调函数,最简单的例子
    python 构造一个可以返回多个值的函数
    python 使用函数参数注解
    Python 两个星号(**)的 参数
    python 什么是位置参数?
    sqlalchemy 的 ORM 与 Core 混合方式使用示例
    sqlalchemy 的 Core 方式使用示例
    sqlalchemy 的 ORM 方式使用示例
    sys.stdin的三种方式
    可以多分类的神经网络
  • 原文地址:https://www.cnblogs.com/Mr-Lin/p/5196706.html
Copyright © 2011-2022 走看看