相关疑难解决方法(0)

在UIPasteBoard中复制NSAttributedString

如何在粘贴板中复制NSAttributedString,以允许用户粘贴或以编程方式粘贴(使用- (void)paste:(id)senderUIResponderStandardEditActions协议).

我试过了:

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不是属性列表值.

如果用户在我的应用中粘贴了粘贴板的内容,我希望保留属性字符串的所有标准和自定义属性.

copy-paste uikit nsattributedstring uipasteboard ios

10
推荐指数
2
解决办法
5583
查看次数