zoukankan      html  css  js  c++  java
  • 简单的在UITableView中隐藏键盘

    1,在UITableView中,要求点击非编辑区域隐藏键盘

    2,在一般控制器中,实现点击"空白"区域隐藏键盘的方法

    代码如下:

    UITableView

    //UITableView 懒加载

    - (UITableView*)tableView {

        if (!_tableView) {

            _tableView = [[UITableView alloc] initWithFrame:[[UIScreen mainScreen] bounds] style:UITableViewStyleGrouped];

            _tableView.delegate = self;

            _tableView.dataSource = self;

            //添加tap手势,隐藏键盘

            UITapGestureRecognizer* tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(hideKeyBorad)];

            [_tableView addGestureRecognizer:tap];

            

        }

        return _tableView;

    }

    //隐藏键盘方法

    - (void)hideKeyBorad {

        [self.view endEditing:YES];

    }

    UIView

    //点击视图的区域隐藏键盘

    - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {

        [self.view endEditing:YES];

    }

  • 相关阅读:
    json批量设置DIV属性
    随机产生div背景颜色变化
    发送验证码倒计时
    购物网站倒计时
    ARC066B
    [Poi2011]Conspiracy
    CF1103E Radix Sum
    NOI2018 冒泡排序
    CometOJ 5E
    NOI2020 命运
  • 原文地址:https://www.cnblogs.com/iOS771722918/p/4365692.html
Copyright © 2011-2022 走看看