码迷,mamicode.com
首页 > 编程语言 > 详细

swift3.0 点击UIScrollView中输入框之外的区域关闭键盘

时间:2017-05-12 18:52:08      阅读:336      评论:0      收藏:0      [点我收藏+]

标签:nbsp   use   ble   res   输入   cto   font   oar   hid   

通过点击事件实现关闭键盘

scrollView: UIScrollView!
title_textField: UITextField!
let hideKeyboardTapGesture = UITapGestureRecognizer(target: self, action: #selector(hideKeyboardTapGesture(sender:)))
scrollView.isUserInteractionEnabled = true
scrollView.addGestureRecognizer(hideKeyboardTapGesture)

关闭实现

func hideKeyboardTapGesture(sender: UITapGestureRecognizer){
        title_textField.resignFirstResponder()
}

 

swift3.0 点击UIScrollView中输入框之外的区域关闭键盘

标签:nbsp   use   ble   res   输入   cto   font   oar   hid   

原文地址:http://www.cnblogs.com/kunH/p/6846598.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!