【发布时间】:2020-06-12 05:07:52
【问题描述】:
我正在标签上呈现我的 HTML 字符串。 另外我已经在 UIView 和 WebView 上渲染了它仍然是 tableview 故障
我应用了这个在标签上呈现 html 的函数。 这是代码。
func getAttributedString(HTMLString: String) -> NSAttributedString {
let data = Data(HTMLString.utf8)
let attributedString = try? NSAttributedString(data: data, options: [.documentType: NSAttributedString.DocumentType.html], documentAttributes: nil)
return attributedString!
}
并在 cellForRowAt 上使用如下
discussionListCell.discriptionLabel.attributedText = self.getAttributedString(HTMLString: discussionResponse[indexPath.row].postMsg ?? "")
她是我收到的带有图像的 HTML 字符串示例。 “他 img src=\"http:\\45.35.4.250\DevImageUpload\60ac0c0f-7751-4088-9a01-466a51a8a5b7.png\">"
在此先感谢。
【问题讨论】:
标签: ios swift uitableview html-parsing