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;

      

  • 相关阅读:
    k8S 搭建集群
    K8S搭建
    华为交换机常用命令
    JSP中动态include和静态include的区别
    什么情况下调用doGet()和doPost()
    get和post的区别
    什么是spring框架
    spring的作用
    什么是DI
    依赖注入的三种实现方式
  • 原文地址:https://www.cnblogs.com/Mr-Lin/p/5196706.html
Copyright © 2011-2022 走看看