在 uitextview 中显示 html 文本 [英] Display html text in uitextview

查看:31
本文介绍了在 uitextview 中显示 html 文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在 textview 中显示 HTML 文本?

How can I display HTML text in textview?

例如

string <h1>Krupal testing <span style="font-weight:
bold;">Customer WYWO</span></h1>

假设文本为粗体,因此它在 textview 中显示为粗体字符串但我想显示普通文本.这可以在 iPhone SDK 中实现吗?

Suppose text is bold so it display in textview as bold string but I want display normal text. Is this possible in the iPhone SDK?

推荐答案

在 iOS 5- 上使用 UIWebView.

Use a UIWebView on iOS 5-.

在 iOS 6+ 上,您可以使用 UITextView.attributedString,请参阅 https://stackoverflow.com/a/20996085 了解如何.

On iOS 6+ you can use UITextView.attributedString, see https://stackoverflow.com/a/20996085 for how.

还有一个未记录 -[UITextView setContentToHTMLString:] 方法.如果您想提交到 AppStore,请不要使用它.

There's also an undocumented -[UITextView setContentToHTMLString:] method. Do not use this if you want to submit to AppStore.

这篇关于在 uitextview 中显示 html 文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆