如何从 iPhone 中的 UITextView 获取空格(“”)后第一个键入的字母?
我想从 UITextView 中输入的句子中获取最后一个单词。例如“Apple i”,在此示例中我需要获取“”(空格)之后的最后一个字母“i”。我想在用户在 UITextView 中输入时执行该功能。我如何从空白(“”)中获取用户之后的单词的第一个字母?有人可以帮忙解决这个问题吗?提前致谢。
I want to get the last word from the typed sentence in UITextView. For example "Apple i", from this example i need to get the last letter 'i' coming after " "(empty space). I want to do the functionality while the user typing in UITextView. How can i get the users first letter of the word after from empty space(" ")? Can anyone please help to solve this problem? Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是字符串逻辑。
您可以将此检查放入
UITextViewDelegate
方法textView:shouldChangeTextInRange:replacementText:
中。不要忘记在此处返回YES
。您还可以使用textViewDidChange:
。Here is the string logic.
You can put this check in your
UITextViewDelegate
methodtextView:shouldChangeTextInRange:replacementText:
. Don't forget to returnYES
here. You could also usetextViewDidChange:
.