Tôi có một chuỗi chứa HTML. Tôi muốn hiển thị HTML trong một điều khiển TextView. Tôi tìm thấy một số mã và thử nó:Cách hiển thị văn bản HTML trong TextView
def = "some html text"
definition.attributedText = NSAttributedString(
data: def.dataUsingEncoding(NSUnicodeStringEncoding, allowLossyConversion: true)!,
options: [ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType],
documentAttributes: nil,
error: nil)
Trên lựa chọn tôi nhận được một lỗi:
[String: String] is not convertible to string.
Ai đó có thể giúp tôi hiển thị HTML trong một TextView?
Dường như NSAttributedString được trả lại một mảng hai chiều. Tôi nghĩ bạn sẽ phải lặp lại thông qua điều tra. – ouflak