Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Loading string in UIWebview

Tags:

How to load a string like below in UIWebview

"\n
\nEgestas rhoncus auctor ac. Risus parturient, mid ultrices nisi.\U00a0
\nAugue ac elementum duis aliquet dolor elementum cum?\U00a0
\nTristique, augue sit lorem adipiscing dis!\U00a0
\nNunc nunc ultricies pellentesque dis dictumst enim
\n
\n"

I am trying to load this same content in 5 webviews..But it is crashing for me..

like image 716
Dev Avatar asked Nov 12 '12 12:11

Dev


1 Answers

You should use:

[webView loadHTMLString:string baseURL:nil];

But note, that you won't preserve line breaks. To preserve line breaks you'll need to replace \n with <\br> (or any valid line breaking html), so this turns into:

[webView loadHTMLString:[string stringByReplacingOccurrencesOfString:@"\n" withString:@"<br/>"] baseURL:nil];
like image 62
MANIAK_dobrii Avatar answered Sep 20 '22 04:09

MANIAK_dobrii