通过 UIButton 将文本从 UITextView 复制到剪贴板(粘贴板)?
有没有办法通过 UIButton 将启用了用户交互的 TextView 中的文本复制到剪贴板?
但是,我希望用户只需单击按钮即可完成操作,而不是用户将手指按住 uitextview 以便复制苹果标准窗口弹出窗口。 (全文)
问候,
Is there any way to copy text from a TextView that has User Interaction is enabled to the clipboard via a UIButton?
But instead of the user holding down his finger on the uitextview so that the apple standard window popups to copy I want the user to be able to do with just the click of the button ..
(Whole text)
Regards,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在按钮的目标操作中,调用
In the button's target action, call
您可以获取当前 UIViewController 显示的实际 UIView,并循环遍历子视图以获取启用了用户交互的所有 UITextView。或者你只有一个文本视图?
您可以通过其 text 属性获取 UITextView 的文本,并使用上述方法 KennyTM 复制此文本:
You could take the actual UIView, that the current UIViewController shows and loop through the subviews to get all UITextView's that have user interaction enabled. Or do you have only one textview?
You can get the text of a UITextView with its text property and copy this text with the method KennyTM described above: