复制文本与iOS到剪贴板(Copy text to clipboard with iOS)

2019-07-19 16:18发布

什么是您的应用程序将文本复制到iPhone的剪贴板中的最佳方式?

他们的文档是简略,比我想要的方式更多的功能...我只是想设置一个字符串作为用户剪贴板。

Answer 1:

虽然接受的答案是如何的好演练UIPasteboard的作品,我想我会发布的相关片段就在这里为大家的方便:

OBJ-C

UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
pasteboard.string = @"paste me somewhere";

雨燕2.2

let pasteBoard = UIPasteboard.generalPasteboard()
pasteBoard.string = "Paste Me !"

斯威夫特3+:

let pasteBoard = UIPasteboard.general
pasteBoard.string = "Paste me!"


Answer 2:

雨燕2.2:

let pasteBoard = UIPasteboard.generalPasteboard()
pasteBoard.string = "Paste Me !"

斯威夫特3:

let pasteBoard = UIPasteboard.general
pasteBoard.string = "Paste me!"


文章来源: Copy text to clipboard with iOS