zoukankan      html  css  js  c++  java
  • ios-点击屏幕,隐藏键盘

    ios-点击屏幕,隐藏键盘

    - (void)getFirstRegist{
        //结束键盘编辑
        __weak typeof(self)weakSelf = self;
    
        UITapGestureRecognizer *tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(hiddenKeyBoard)];//注意是UITapGestureRecognizer
        NSOperationQueue *mainQueue = [NSOperationQueue mainQueue];//主队列
    
        //在键盘出现之前,这个函数会被触发(键盘内置的方法,来获取这个通知中的消息)
        [[NSNotificationCenter defaultCenter] addObserverForName:UIKeyboardWillShowNotification object:nil queue:mainQueue usingBlock:^(NSNotification *note) {
            [weakSelf.view addGestureRecognizer:tapGestureRecognizer];
        }];
        [[NSNotificationCenter defaultCenter] addObserverForName:UIKeyboardWillHideNotification object:nil queue:mainQueue usingBlock:^(NSNotification *note) {
            [weakSelf.view removeGestureRecognizer:tapGestureRecognizer];
        }];
    }
    
    - (void)hiddenKeyBoard{
        [self.view endEditing:YES];
    }
    
  • 相关阅读:
    数据库-自定义函数
    数据库-存储过程
    数据库配置
    水电费管理系统需求分析与设计_待完善
    SQL中Group By的使用
    部分查询功能语句
    10-11数据库练习
    Oracle-SQL
    开发环境之Gradle
    解决程序端口占用
  • 原文地址:https://www.cnblogs.com/AbeDay/p/5026929.html
Copyright © 2011-2022 走看看