Display HTML content as text in a UIWebView

I work in an application in which the user can send email, and when displaying email we get HTML, and in the tags HTMLwe get the text of the email and some formatting, like paragraphs, in bold. Currently I used UIWebView, but now my problem is that if any user has sent some kind of input HTML, then I need to display this as plain text.

In the HTML response, I have text that should be treated like HTML, and it works fine with the web view. But what if someone asks me to send the HTML code as an email, I find the HTML code (allows you to take the construction of the form c) in the email, and when I show it in the WebView, it shows the form, not the text, which I typed.

I want to point out something that is marked as displayable html content as text, and the rest of the HTML content can take effect.

+4
source share
1 answer

You will have to avoid special characters in your HTML code.

For example, the following HTML

<p>Hello world!</p>

should be presented as:

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

Swift, : https://github.com/Halotis/EscapeHTML

+1

All Articles