归因UITextView不适用于韩文符号

归因UITextView不适用于韩文符号。 重现步骤:

  • 将UITextView添加到窗体。
  • 使用下面的代码:
NSDictionary *attributes = @{ NSFontAttributeName:[UIFont fontWithName:@"HelveticaNeue" size:15], NSForegroundColorAttributeName:[UIColor blackColor]}; [textView setAttributes:attributes range:NSMakeRange(0, textView.text.length)]; 
  • 运行该应用程序,在韩语(에서보냄)上键入任何文本,然后点击或按Enter键。

韩文文本将会消失或将被几个垃圾标志取代。 为什么? 我该如何解决?

PS这个问题是一个有趣的答案UITextField文字消失每隔一个按键但是我在代码上创buildUITextView对象。

使用这个代码它会帮助你。

  //[_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]; 

以下不正确的代码工作正常:

 NSDictionary *attributes = @{ NSFontAttributeName:[/*UIFont fontWithName:@"HelveticaNeue" size:15],*/ NSForegroundColorAttributeName:[UIColor blackColor]}; [textView addAttributes:attributes range:NSMakeRange(0, textView.text.length)];