zoukankan      html  css  js  c++  java
  • 点击任意位置隐藏键盘

    给view加一个点击事件,点击时收起键盘:

        override func viewDidLoad() {
            super.viewDidLoad()
    
            let tap = UITapGestureRecognizer(target: self, action: #selector(self.dismissKeyboard))
            tap.cancelsTouchesInView = false
            self.view.addGestureRecognizer(tap)
        }
    
        @objc func dismissKeyboard() {
            self.view.endEditing(true)
        }

    open var cancelsTouchesInView: Bool // default is YES. causes touchesCancelled:withEvent: or pressesCancelled:withEvent: to be sent to the view for all touches or presses recognized as part of this gesture immediately before the action method is called.

    如果不加tap.cancelsTouchesInView = false这一句,view中其他的点击事件会失效,例如tableview的didSelectRow。

  • 相关阅读:
    图像滤波
    直方图histeq
    直方图
    基于灰度变换的图像增强
    图像增强
    图像旋转和缩放
    图像点运算
    像素的连接与联通
    程序员进阶之算法练习(一)
    RxSwift 系列(二)
  • 原文地址:https://www.cnblogs.com/argenbarbie/p/12513759.html
Copyright © 2011-2022 走看看