4

私はアラビア語の文字列を使用しており、内部で正当化したいと考えていますUITextView

textView で着信 attributingString を取得し、列挙して次のNSParagraphStyleAttributeNameように編集します。

NSMutableAttributedString * mstring = [[NSMutableAttributedString alloc] initWithAttributedString:_textView.attributedText];

[_textView.attributedText enumerateAttribute:NSParagraphStyleAttributeName inRange:NSMakeRange(0, _textView.attributedText.length) options:0
                                  usingBlock:^(id value, NSRange range, BOOL *stop) {
                                      NSMutableParagraphStyle * paragraphStyle = (NSMutableParagraphStyle *)value;
                                      if (paragraphStyle.alignment == NSTextAlignmentRight) {


                                          paragraphStyle.lineBreakMode = NSLineBreakByWordWrapping;
                                          paragraphStyle.alignment = NSTextAlignmentJustified;
                                          paragraphStyle.baseWritingDirection = NSWritingDirectionRightToLeft;
                                          [mstring addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:range];
                                          [self.textView setAttributedText:mstring];
                                      }


}];

属性文字列がアラビア語の場合はアプリケーションがクラッシュしましたが、英語の場合は正常に動作していることがわかりました。

この問題を解決するためのアイデアはありますか?

4

0 に答える 0