点击一次复制 UITextView 文本子字符串

发布于 2024-09-29 03:50:38 字数 196 浏览 2 评论 0原文

假设您有一个填充了一大块文本的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

故事灯 2024-10-06 03:50:38

我知道您看过 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 with setValue:forPasteboardType:?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文