用iPhone SDK将文本复制到剪贴板
在应用程序中将文本复制到iPhone剪贴板的最佳方法是什么?
他们的文档是粗略的,有比我想要的更多的function…我只是想设置一个string作为用户剪贴板。
虽然接受的答案是UIPasteboard如何工作的一个很好的演练,但我想我会在这里为大家的方便张贴相关的片段:
OBJ-C
UIPasteboard *pasteboard = [UIPasteboard generalPasteboard]; pasteboard.string = @"paste me somewhere";
Swift 2.2:
let pasteBoard = UIPasteboard.generalPasteboard() pasteBoard.string = "Paste Me !"
Swift 3:
let pasteBoard = UIPasteboard.general pasteBoard.string = "Paste me!"
Swift 2.2:
let pasteBoard = UIPasteboard.generalPasteboard() pasteBoard.string = "Paste Me !"
Swift 3:
let pasteBoard = UIPasteboard.general pasteBoard.string = "Paste me!"