防止在点击UITextField时出现键盘 [英] Prevent Keyboard from appearing when tapping on UITextField

查看:119
本文介绍了防止在点击UITextField时出现键盘的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 UITextField 来显示计算结果,但是我不希望在用户点击 UITextField .

I'm using a UITextField to show results of a calculation but I don't want the keyboard to appear when the user taps on the UITextField.

我使用的是UITextField,因为我仍然希望用户能够将计算结果复制并粘贴回UITextField中,但是我不希望键盘显示出来.

I'm using a UITextField because I still want the user to be able to Copy and Paste the calculation back into the UITextField, but I don't want the keyboard to show up.

UIKeyboardWillHide 仅在显示键盘后才能起作用.

UIKeyboardWillHide only works after the keyboard is displayed.

推荐答案

Swift 4.2,这对我有用. 放入viewDidLoad()

Swift 4.2, This works for me. put in viewDidLoad()

//It will Hide Keyboard
textField.inputView = UIView()
//It will Hide Keyboard tool bar
textField.inputAccessoryView = UIView()
//It will Hide the cursor
textField.tintColor = .white

这篇关于防止在点击UITextField时出现键盘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆