【发布时间】:2015-08-13 18:21:01
【问题描述】:
我有一个包含 HTML 的字符串。我想在 TextView 控件中显示 HTML。我找到了一些代码并尝试了它:
def = "some html text"
definition.attributedText = NSAttributedString(
data: def.dataUsingEncoding(NSUnicodeStringEncoding, allowLossyConversion: true)!,
options: [ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType],
documentAttributes: nil,
error: nil)
在选项上我得到一个错误:
[String: String] 不能转换为字符串。
有人可以帮我在 TextView 中显示 HTML 吗?
【问题讨论】:
-
看起来 NSAttributedString 正在返回一个二维数组。我认为您将不得不遍历枚举。
标签: html ios swift swift2 uitextview