从 iPhone 中的 UILabel 复制文本

发布于 2024-11-10 00:46:13 字数 477 浏览 2 评论 0原文

我有一种情况,我想从 UILabel 复制文本作为 iPhone 中出现的默认剪切/复制菜单。我知道我可以使用 UITextField 来启用此菜单,但键盘会弹出,当我进行编辑时返回否,键盘没有显示,默认的复制/剪切菜单也没有显示。

我尝试使用 UITextView 并取消选中 UITextView 属性中的 diting 属性,但它没有给我一个正确的解决方案。因为当字体超过 UITextView 的高度时。它转到下一行,并且无法在我现在拥有的视图中正确对齐。

我看到这篇文章“在 UILabel 上显示 iPhone 剪切复制粘贴菜单”在堆栈溢出本身中,它表示我需要的相同功能。

我从 git 下载了源代码,但出现了 23 个错误。

如何实现这一点?

I have a situation where i want to copy the text from UILabel as a default cut/copy menu which appears in iPhone.I know that i can use a UITextField for enabling this menu but the key pad pops up and when i make the editing to return no,the keypad is not showing up and the default copy/cut menu is also not showing up.

I tried to use UITextView and unchecked the diting property in the properties of the UITextView,but it didn't gave me a proper solution.Because when the font exceeds the UITextView's height. It goes to the next line and it cannot be aligned properly in a view which i have now.

I came across this post "Show iPhone cut copy paste menu on UILabel" in stack overflow itself which says the same functionality which I need.

I downloaded the source code from git but I got 23 errors.

How can implement this ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

淡莣 2024-11-17 00:46:13

这个github项目编译得很好,我已经测试过它可以工作

UILabel copy using menu

This github project is compiled fine and I have tested it it's working

UILabel copy using menu

懷念過去 2024-11-17 00:46:13

您可能还想查看 GitHub 上的 HTCopyableLabel。它是 UILabel 子类,可以轻松复制文本。

You may also want to check out HTCopyableLabel on GitHub. It's a UILabel subclass that makes copying text easy.

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