将 UITextView 的可编辑设置为 NO 总是会放弃 FirstResponder。可以避免吗?
我的应用程序基本上可以让您发送一段文本。当用户点击发送时,我想禁用包含文本的文本视图,以便用户在发送文本时无法再编辑它。看来,将enableUserInteraction或editable设置为NO总是会放弃第一响应者(基本上键盘被解雇),这是我不想要的行为。我想保持键盘显示。这附近还有吗?提前致谢。
My app basically lets you send a piece of text. When the user taps send, I would like to disable the text view which contains the text so the user can't edit it anymore as the text is being sent. It seems though that setting either enableUserInteraction or editable to NO always resigns the first responder (basically the keyboard is dismissed) which is a behavior I don't want. I want to keep the keyboard displayed. Is there anyway around this? Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
虽然我不太明白为什么您认为在没有任何内容可编辑的情况下将键盘保留在屏幕上是个好主意,但您可以通过隐藏
UITextField
并创建第一响应者来实现此目的。While I don't really understand why you think it's a good idea to keep the keyboard on screen if there's nothing to edit, you can achieve this by having a hidden
UITextField
and making that first responder.如果 UITextView 的 委托方法
textView:shouldChangeTextInRange:replacementText:
返回 NO,其内容不会改变。If the UITextView's delegate method
textView:shouldChangeTextInRange:replacementText:
returns NO, its contents will not be changed.