我有一个UITextView
这将有图像的混合(如NSTextAttachment
) 和字符串。这UITextView
是不可选择的,所以我可以使用:
- (BOOL)textView:(UITextView *)textView shouldInteractWithTextAttachment:(NSTextAttachment *)textAttachment inRange:(NSRange)characterRange
我该如何删除textAttachment
在方法中?
您可以使用replaceCharactersInRange:withString:
of NSMutableAttributedString
删除附件(您将范围作为参数UITextViewDelegate
方法):
//Retrieve the attributed string
NSMutableAttributedString *mutableAttr = [[textView attributedText] mutableCopy];
//Remove the attachment
[mutableAttr replaceCharactersInRange:range withString:@""];
//Set the new attributed string
[textView setAttributedText:mutableAttr];
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)