相关疑难解决方法(0)

UITextView与NSAttributedString和自定义属性不起作用

使用UITextView时,我尝试将自定义属性添加到属性字符串.但是,在分配到UITextView的attributedText后,所有自定义键都将丢失.像这样:

NSMutableAttributedString *lString = [[ NSMutableAttributedString alloc ] initWithString: @"astring"
                                             attributes: @{ @"customkey": @"customvalue" }];
NSLog(@"string: %@", lString);  // shows customkey present
textView.attributedText = lString;
NSLog(@"result: %@", self.textView.attributedText);   // shows customkey missing
Run Code Online (Sandbox Code Playgroud)

这应该有用吗?

cocoa-touch uitextview nsattributedstring ios

7
推荐指数
2
解决办法
2万
查看次数

标签 统计

cocoa-touch ×1

ios ×1

nsattributedstring ×1

uitextview ×1