归因于UITextView不适用于韩语符号。重现的步骤:
NSDictionary *attributes = @{ NSFontAttributeName:[UIFont fontWithName:@"HelveticaNeue" size:15], NSForegroundColorAttributeName:[UIColor blackColor]}; [textView setAttributes:attributes range:NSMakeRange(0, textView.text.length)];
韩文文本将消失或将被多个垃圾符号替换。为什么?我该如何解决?
P.S。问题UITextField text disappears on every other keystroke是一个有趣的答案但是我在代码上创建了UITextView对象。
答案 0 :(得分:0)
使用此代码可以帮助您。
//[_txtViewChallangeDescription setBackgroundColor:[UIColor redColor]];
_txtViewChallangeDescription.font = [UIFont fontWithName:kFontHelvetica size:kFontSize14];
[_txtViewChallangeDescription setTextColor:[UIColor blackColor]];
[_txtViewChallangeDescription setEditable:NO];
_txtViewChallangeDescription.delegate=self;
_txtViewChallangeDescription.scrollEnabled=NO;
_txtViewChallangeDescription.textContainer.lineFragmentPadding = 0;
_txtViewChallangeDescription.textContainerInset = UIEdgeInsetsZero;
NSDictionary *attrDict = @{
NSFontAttributeName : [UIFont fontWithName:kFontHelvetica size:kFontSize14],
NSForegroundColorAttributeName :[UIColor colorWithRed:152.0/255.0f green:132.0/255.0f blue:43.0/255.0f alpha:1.0f]
};
[_txtViewChallangeDescription setLinkTextAttributes:attrDict];
答案 1 :(得分:0)
以下不正确的代码可以正常运行:
NSDictionary *attributes = @{
NSFontAttributeName:[/*UIFont fontWithName:@"HelveticaNeue" size:15],*/
NSForegroundColorAttributeName:[UIColor blackColor]};
[textView addAttributes:attributes
range:NSMakeRange(0, textView.text.length)];