这可能是一件容易的事,但我就是想不通——如何结束编辑文本视图?如何让键盘消失?还是我必须在它外面点击才能让它消失?
This is probably an easy thing to do, but I just can't figure it out - how do I end editing athe textview? how can I get the keyboard to disappear? or do I have to click outside it to make it go away?
首先,像这样一个(说实话)相当简单的问题让我想知道您是否尝试过阅读文档或在互联网上搜索.
First, a (to be honest) fairly simple question like this makes me wonder if you've tried reading the documentation, or searching on the internet.
搜索Apple 文档 UITextView"为您提供 此链接 到类文档.同样,这里是文档UITextViewDelegate.
Searching for "Apple documentation UITextView" gives you this link to the class documentation. Similarly, here is the documentation for the UITextViewDelegate.
搜索UITextView 简单示例"会为您提供这个有用示例.
Searching for "UITextView simple example" gives you this useful example.
搜索UITextView 关闭键盘",第一个点击似乎是 准确回答您的问题.(尽管他在返回键上关闭了键盘,这可能不是您想要的.)(编辑 - 从您的第二条评论看来,这正是您想要的.)
Searching for "UITextView dismiss keyboard", the first hit seems to answer your question exactly. (Although he dismisses the keyboard on a return key, which may not be what you want.) (Edit - it seems from your second comment it's exactly what you want.)
附:上面的人是正确的,如果有点简洁(可以理解).你需要实现一个 UITextViewDelegate.在该委托中,如果您想在返回键上隐藏键盘,请实现 shouldChangeTextInRange,查找 @" " 并在收到第一响应者时辞职.或者,在您的 UI 中添加完成编辑"按钮,并在用户按下它时退出第一响应者.
P.S. The people above are correct, if a little terse (understandably). You need to implement a UITextViewDelegate. In that delegate, if you want to hide the keyboard on a return key, implement shouldChangeTextInRange, look for a @" " and resign first responder if you get it. Alternatively, add a "Done editing" button to your UI, and resign first responder if the user presses it.
这篇关于iPhone - UITextView 的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
在与中心点成给定角度的直线相交的 UIView 矩形上Find the CGPoint on a UIView rectangle intersected by a straight line at a given angle from the center point(在与中心点成给定角度的直线相交
是否可以使用字符串和 int 引用变量?Is it possible to reference a variable with a string and an int?(是否可以使用字符串和 int 引用变量?)
是否有适用于 iPhone 的本机 YAML 库?Is there a native YAML library for iPhone?(是否有适用于 iPhone 的本机 YAML 库?)
在 iOS 9 Shortcut Bar only 模式下,与键盘顶部对齐的View aligned to top of keyboard appears in wrong place in iOS 9 Shortcut Bar only mode(在 iOS 9 Shortcut Bar only 模式下,与键盘顶部对齐的视
以编程方式在android中的软输入键盘上禁用语音到Disable speech to text button (Micro phone) on soft input keyboard in android programmatically(以编程方式在android中的软输入键盘上禁用语
UI键盘类型UIkeyboard type(UI键盘类型)