快速禁用UITextfield的用户输入 [英] Disabling user input for UITextfield in swift

查看:113
本文介绍了快速禁用UITextfield的用户输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道一个相当琐碎的问题.但是我在网上找不到任何东西.

pretty trivial question, I know. But I can not find anything online.

我需要禁止用户编辑文本字段内的文本.这样,当单击文本时,不会显示键盘.

I need to disable the user from being able to edit the text inside of a text field. So that when the click on the text, a keyboard doesn't show up.

有什么想法吗?

一个程序化的解决方案,或者如果可能通过情节提要,那将是一个很好的选择.

A programmatic solution or if it is possible through storyboards would be great.

推荐答案

尝试一下:

Swift 2.0 :

textField.userInteractionEnabled = false

Swift 3.0 :

textField.isUserInteractionEnabled = false

或者在情节提要中取消选中已启用用户交互"

Or in storyboard uncheck "User Interaction Enabled"

这篇关于快速禁用UITextfield的用户输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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