lu yuan
lu yuan

Reputation: 7227

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.

Upvotes: 5

Views: 3540

Answers (2)

lu yuan
lu yuan

Reputation: 7227

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

Upvotes: 9

Fab1n
Fab1n

Reputation: 2284

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.

Upvotes: 1

Related Questions