我正在使用阿拉伯字符串,我想在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];
}
}];
我发现,如果属性字符串是阿拉伯语,则应用程序崩溃,但如果是英语,则表明它正常工作。
有什么想法可以解决这个问题吗?