Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add line breaks when displaying a long string in UIWebView

When displaying a paragraph with some long strings without line breaks in an UIWebView, the size of the character is too small for reading, as show in the following pic. Is there anyway to automatically add line breaks in the long strings as in the UILabel? Thanks in advance! enter image description here

ps. the UIWebView is used to display an email body.

like image 810
lu yuan Avatar asked Sep 08 '12 10:09

lu yuan


2 Answers

set the css as : style="word-break:break-all" to solve this problem

like image 134
lu yuan Avatar answered Nov 13 '22 11:11

lu yuan


Simply NO. UIWebView is made to parse HTML-Markup. The breaking has to be done there. \n will do it.

Other than that, you should rethink your HTML-Box-Model being responsive.

If you only want to display text, then use UITextView instead of UIWebView and switch to UIWebView, if its HTML. I think Mail.app on iOS does it like that. UITextView text is appropriately scaled.

like image 33
Fab1n Avatar answered Nov 13 '22 12:11

Fab1n