1

I have an application with a chat, which the design is made with code in objective-c, but in the dialogues the words are broken. How can I justify the text or do a kind of word wrap for the UItextview?

This is an image of what I'm talking about https://serving.photos.photobox.com/5690512502fd6b9b94cda7ff55dae480af40b3eaf5d952204e938af42be59226a480c160.jpg

I added a HypherationFactor of 1 but the problem is not solved, just fix some. I've been trying for a while and I can not do it.

_textView=[[UITextView alloc] init];
[_textView setTextContainerInset:UIEdgeInsetsZero];
_textView.textContainer.lineFragmentPadding = 0;
_textView.dataDetectorTypes=UIDataDetectorTypeAll;
_textView.font=[UIFont systemFontOfSize:17]; 
_textView.textColor=kTextColor;
_textView.layoutManager.hyphenationFactor = 1;
_textView.backgroundColor=[UIColor clearColor];
_textView.scrollEnabled=NO;
_textView.editable=NO;

I want the words to be understood; for example: tempera- ture

  • Hi Esteban and welcome to StackOverflow. I have copied-pasted your code in a test project, only adding a frame to _textview and some text, and it works as you'd expect, by truncating words by their syllables. Are you sure you're not messing up its line break management somewhere else in your code? – il3v Dec 24 '18 at 15:11

1 Answers1

0

You Just need to add one line code in your textView code.

textView.textContainer.lineBreakMode = NSLineBreakByWordWrapping;

Eric Aya
  • 69,473
  • 35
  • 181
  • 253
Sagar koyani
  • 403
  • 2
  • 12