zoukankan      html  css  js  c++  java
  • 搜索栏的使用(UISearchBar)(跳转到下一个页面,搜索栏消失)

    导航栏上 添加按钮和触发事件(一句代码添加导航栏的按钮和方法)
      self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"删除" style:UIBarButtonItemStylePlain target:self action:@selector(selectRightAction:)];
     
    1、初始化搜索栏
    UISearchBar *searchBar = [[UISearchBar alloc]initWithFrame:CGRectmake(100,100,100,100)];
      // 设置搜索栏的圆角
      *** searchBar.layer.cornerRadius = 10;
     
    // 挂上代理(要用到代理的里面的方法,让搜索栏回收键盘)
     searchBar.delegate = self;
     
    // 设置搜索栏的tag值(目的就是让搜索栏的消失和出现)
     
    2、让搜索栏添加到导航栏上
    [self.navigationController.navigationBar addSubview: searchBar]
     
     
    ————搜索栏(点击回收键盘)
    - (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar
    {
       [searchBar resignFirstResponder];
    }
     
    ———让搜索栏出现
    -(void)viewWillAppear:(BOOL)animated
    {
     
        [self.navigationController,navigationBar viewWithTag:100].hidden = NO;
    }
     
    —让搜索栏消失(跳转到下一个页面)
    - (void)viewDidDisappear:(BOOL)animated
    {
     
    [self . navigationController . navigationBar viewWithTag: 100].hidden =  YES;
     
     
    }
  • 相关阅读:
    day37 事务
    小组分享
    day36 pymysql 索引
    day 35 多表查询
    day 35 作业
    day 34 作业
    AST 节点类型对照表
    babel _shallowEqual.default
    js Proxy
    Symbol
  • 原文地址:https://www.cnblogs.com/wukun16/p/4844760.html
Copyright © 2011-2022 走看看