aryaxt / iOS-Rich-Text-Editor

A Rich Text Editor for iOS
Other
893 stars 158 forks source link

Pre-populate with HTML? #48

Closed randyarrowood closed 10 years ago

randyarrowood commented 10 years ago

Great control. Sorry for the basic question. I'm struggling to figure out how to pre-populate with formatted text. I'm setting the .text property of the object and it shows the full HTML inside the control. Is there a method for populating/setting the contents with HTML?

randyarrowood commented 10 years ago

I think I found it... .attributedText

myRichTextView.attributedText = [[NSAttributedString alloc] initWithData:[myHTMLString dataUsingEncoding:NSUTF8StringEncoding] options:@{NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType, NSCharacterEncodingDocumentAttribute: @(NSUTF8StringEncoding)} documentAttributes:nil error:nil];