点击一次复制 UITextView 文本子字符串
假设您有一个填充了一大块文本的 UITextView。当用户点击文本中的单词时,我希望应用程序立即复制(检索字符串)该单词。据您所知,有什么实用的方法可以做到这一点吗?
旁注:我查看了 UIPasteboard 等,但这不是我正在寻找的,因为它不提供一键式解决方案。这里的中心目标是一键式的概念。即点击文本一次,我就会检索 NSString。
Say you've got a UITextView populated with a chunk of text. When a user taps on a word within the text I want the app to copy (retrieve the string) that word immediately. In your knowledge, is there any practical way to do this?
Side note: I looked at UIPasteboard and all that but it is NOT what I'm looking for as it does not offer a one-tap solution. Central aim here is the concept of one-tap. I.e. Tap the text once and I retrieve the NSString.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我知道您看过 UIPasteboard,但是您是否考虑过检测触摸,然后使用
setValue:forPasteboardType:
自行设置[textView text]
?I know you looked at UIPasteboard, but did you consider playing around with detecting touches and then setting the
[textView text]
yourself withsetValue:forPasteboardType:
?