8
나는 paragraphStyle.hyphenationFactor = 1
을 사용하지만 영어 텍스트에 대해서만 잘 작동합니다. UITextView
에서 영어 이외의 텍스트가있는 하이픈을 사용하거나 로케일을 UITextView
으로 설정하는 방법은 무엇입니까?영어 이외의 텍스트로 된 UITextView에서 하이픈 넣기를 활성화하는 방법은 무엇입니까?
나는 paragraphStyle.hyphenationFactor = 1
을 사용하지만 영어 텍스트에 대해서만 잘 작동합니다. UITextView
에서 영어 이외의 텍스트가있는 하이픈을 사용하거나 로케일을 UITextView
으로 설정하는 방법은 무엇입니까?영어 이외의 텍스트로 된 UITextView에서 하이픈 넣기를 활성화하는 방법은 무엇입니까?
및 this 나는 발견 솔루션 :
NSError *error = nil;
NSLocale *locale = [NSLocale localeWithLocaleIdentifier:@"LOCALE"];
NSString *hyphenatedString = [string softHyphenatedStringWithLocale:locale error:&error];
NSString *htmlString = [NSString stringWithFormat:@"<html> \n"
"<head> \n"
"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"> \n"
"<style type=\"text/css\"> \n"
"html {-webkit-hyphens: auto; } \n"
"</style> \n"
"</head> \n"
"<body>%@</body> \n"
"</html>", hyphenatedString];
@try {
SEL setContentToHTMLString = NSSelectorFromString([@[@"set", @"Content", @"To", @"HTML", @"String", @":"] componentsJoinedByString:@""]);
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
[textView performSelector:setContentToHTMLString withObject:htmlString];
#pragma clang diagnostic pop
}
@catch (NSException *exception)
{
textView.text = hyphenatedString;
}