4

我有一个可变属性字符串,我添加了一个图像文本附件。

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];

我现在如何获取该文本附件并将其替换为图像应该位于文本正文中的位置的字符串?

4

1 回答 1

1

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

textStorage.edited([.EditedAttributes], range: range, changeInLength: 0)
于 2015-11-26T20:08:14.103 回答