如何在粘贴板中复制NSAttributedString,以允许用户粘贴或以编程方式粘贴(使用- (void)paste:(id)sender
UIResponderStandardEditActions协议).
我试过了:
UIPasteboard *pasteBoard = [UIPasteboard generalPasteboard];
[pasteBoard setValue:attributedString forPasteboardType:(NSString *)kUTTypeRTF];
Run Code Online (Sandbox Code Playgroud)
但这次崩溃:
-[UIPasteboard setValue:forPasteboardType:]: value is not a valid property list type'
Run Code Online (Sandbox Code Playgroud)
这是预期的,因为NSAttributedString不是属性列表值.
如果用户在我的应用中粘贴了粘贴板的内容,我希望保留属性字符串的所有标准和自定义属性.