【发布时间】:2012-09-18 00:55:07
【问题描述】:
如何在粘贴板中复制 NSAttributedString,以允许用户粘贴或以编程方式粘贴(使用 - (void)paste:(id)sender,来自 UIResponderStandardEditActions 协议)。
我试过了:
UIPasteboard *pasteBoard = [UIPasteboard generalPasteboard];
[pasteBoard setValue:attributedString forPasteboardType:(NSString *)kUTTypeRTF];
但是这次崩溃是:
-[UIPasteboard setValue:forPasteboardType:]: value is not a valid property list type'
这是意料之中的,因为 NSAttributedString 不是属性列表值。
如果用户在我的应用中粘贴粘贴板的内容,我想保留属性字符串的所有标准和自定义属性。
【问题讨论】:
-
对 UIPasteBoard 和 NSAttributedString 有一些见解,可能很有价值:stackoverflow.com/a/38211885/1054573
标签: ios uikit copy-paste nsattributedstring uipasteboard