我想知道是否可以通过代码将一些文本复制到iphone键盘--I.E。他们按下名为“复制链接到剪贴板”的按钮,它会复制链接到剪贴板?
感谢。
答案 0 :(得分:22)
通过
复制普通字符串UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
pasteboard.string = @"my test string";
通过例如
的URLUIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
pasteboard.URL = [NSURL URLWithString:@"http://stackoverflow.com/questions/4060471/iphone-copy-something-to-clipboard-via-code"];
答案 1 :(得分:4)
UIPasteboard
就是您所需要的:
http://mobileorchard.com/new-in-iphone-30-tutorial-series-part-3-copy-paste-with-uipasteboard/
答案 2 :(得分:0)
UIPasteboard.general.string = "This is the copied text"