ios – 如何在NSAttributedString中删除和替换NSTextAttachment

ios – 如何在NSAttributedString中删除和替换NSTextAttachment,第1张

概述我有一个可变的属性字符串,我添加了图像文本附件. NSMutableAttributedString* attributedString = [_textField.attributedText mutableCopy];NSMutableDictionary* dict = [_homeFeedCommentsViewController.inputData.array_extraEleme 我有一个可变的属性字符串,我添加了图像文本附件.

NSMutableAttributedString* attributedString = [_textFIEld.attributedText mutablecopy];NSMutableDictionary* dict = [_homeFeedCommentsVIEwController.inputData.array_extraElements objectAtIndex:0];NSNumber* indexObject = [NSNumber numberWithUnsignedLong:attributedString.length];[dict setobject:indexObject forKey:@"LocationIndex"];[attributedString insertAttributedString:imageAsAttributedString atIndex:attributedString.length];

我现在如何获得该文本附件&在图像应该位于文本正文的位置用字符串替换它?

解决方法 只需告诉文本存储,您更新了相应附件字符范围的属性:

textStorage.edited([.EditedAttributes],range: range,changeInLength: 0)
总结

以上是内存溢出为你收集整理的ios – 如何在NSAttributedString中删除和替换NSTextAttachment全部内容,希望文章能够帮你解决ios – 如何在NSAttributedString中删除和替换NSTextAttachment所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1027282.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-23
下一篇2022-05-23

发表评论

登录后才能评论

评论列表(0条)

    保存