如何使 UITextView 不可编辑并且不希望键盘显示
在 UITextView
中有一个只读文本,根本不需要任何用户交互,意味着不希望编辑文本,甚至不希望显示键盘。我想让 UITextView 可滚动。
现在发生的情况是它不可滚动,内容可编辑,键盘显示,但边框的底墙不显示。如果有人可以帮助我解决这个问题。会非常感激。
提前致谢。
In a UITextView
have a text which is for readonly and dont want any userinteraction at all means dont want text to be edited and even dont want keyboard to showup. I want to make UITextView
scrollable.
Right now what happening is that it is not scrollable and the content is editable and keyboard shows up and bottom wall of the border is not showing. If anyone can help me with this issue. Will appreciate it so much.
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
设置
可编辑
/isEditable
属性为NO
/false
。Swift 3、4:
Swift 1、2:
Objective-C:
Set the
editable
/isEditable
property toNO
/false
.Swift 3, 4:
Swift 1, 2:
Objective-C:
文档中提到了这一点。
关于滚动;当内容大小超过 UITextView 的框架大小时,您的 UITextView 将滚动。
It's mentioned in the documentation.
And about the scrolling; Your UITextView will scroll when the content size exceeds the frame size of your UITextView.
您还可以通过故事板设置行为。只需取消选中“可编辑”,如下图所示
you can also set the behavior through storyboard. just uncheck the 'editable' like the image below
更新 Swift 3+
editable
和selectable
已重命名为isEditable
和isSelectable
Update Swift 3+
editable
andselectable
have been renamed toisEditable
andisSelectable