ios - How to load HTML in UITextView? -


i have html contents achor tag in it. want load html content in uitextview.

you can convert html document nsattributedstring so:

// html needs in form of nsstring nserror *error = nil; nsattributedstring *attstring = [[nsattributedstring alloc] initwithdata:[html datausingencoding:nsutf8stringencoding] options:@{nsdocumenttypedocumentattribute:nshtmltextdocumenttype, nscharacterencodingdocumentattribute:@(nsutf8stringencoding)} documentattributes:nil error:&error]; if (error) {     nslog(@"error: %@ %s %i", error.localizeddescription, __func__, __line__); } else {     // clear text view     textview.text = @"";     // append attributed string     [textview.textstorage appendattributedstring:attstring]; }  

if come across problems try changing encoding nsasciistringencoding in places.


Comments

Popular posts from this blog

jquery - How do you format the date used in the popover widget title of FullCalendar? -

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -