我在中显示htmlUITextView
by:
[self.textView setValue:@"<b>Content</b>" forKey:@"contentToHTMLString"];
,
编辑内容后UITextView
,我想获取包含 html 的内容,所以我使用:
[self.textView valueForKey:@"contentToHTMLString"];
但是应用程序崩溃了,如何修复?
对于 ios 7 使用以下代码。
NSString *htmlString = @"<h1>Header</h1><h2>Subheader</h2><p>Some <em>text</em></p><img src='http://blogs.babble.com/famecrawler/files/2010/11/mickey_mouse-1097.jpg' width=70 height=100 />";
NSAttributedString *attributedString = [[NSAttributedString alloc] initWithData:[htmlString dataUsingEncoding:NSUnicodeStringEncoding] options:@{ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType } documentAttributes:nil error:nil];
textView.attributedText = attributedString;
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)