Bhupesh
Bhupesh

Reputation: 2310

Display HTML content as a Text in UIWebView

I am working in application in which user can send email, and while displaying the email we are getting HTML, And in that HTML tags we are getting email text and some formatting like paragraphs, bold fields. Currently I have used UIWebView but now my problem is that if any user has send some HTML input at that time I need to display that like simple text only.

In the response HTML I have some text to consider as a HTML and it is working fine with web view. But what if some one ask me for HTML code to send as a email, I type some HTML code (lets take a Form design with ) in email message and when I show it in WebView it shows the form not the text I typed.

I want to mark something so marked html content displays as a text and rest of HTML content may take its effect.

Upvotes: 4

Views: 848

Answers (1)

Andrei Papancea
Andrei Papancea

Reputation: 2224

You'll have to escape special characters in your HTML code.

For instance the following HTML

<p>Hello world!</p>

should be represented as:

&lt;p&gt;Hello world!&lt;/p&gt;

Here's a Swift project that simplifies this for you: https://github.com/Halotis/EscapeHTML

Upvotes: 1

Related Questions