iOS UIWebView UITextView UILabel 显示 HTML内容
2016-10-15 09:44
489 查看
// 获取html到NSString
NSURL *url = [NSURL URLWithString:@"http://xxx/xxx/xxx"];
NSString *strHtml = [NSString stringWithContentsOfURL:url encoding:NSUTF8StringEncoding error:nil];
// 显示到UIWebView
[webView loadHTMLString:strHtml baseURL:nil];
// 显示到UITextView
(用不了)
[textView setContentToHTMLString:strHtml];
// iOS6 之后的UITextView和UILabel 有attributedText 属性,可以设置字符串显示的多样化显示。
NSAttributedString *attributedString = [[NSAttributedString alloc] initWithData:[strHtml dataUsingEncoding:NSUnicodeStringEncoding] options:@{NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType } documentAttributes:nil error:nil];
textView.attributedText = attributedString;
NSURL *url = [NSURL URLWithString:@"http://xxx/xxx/xxx"];
NSString *strHtml = [NSString stringWithContentsOfURL:url encoding:NSUTF8StringEncoding error:nil];
// 显示到UIWebView
[webView loadHTMLString:strHtml baseURL:nil];
// 显示到UITextView
(用不了)
[textView setContentToHTMLString:strHtml];
// iOS6 之后的UITextView和UILabel 有attributedText 属性,可以设置字符串显示的多样化显示。
NSAttributedString *attributedString = [[NSAttributedString alloc] initWithData:[strHtml dataUsingEncoding:NSUnicodeStringEncoding] options:@{NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType } documentAttributes:nil error:nil];
textView.attributedText = attributedString;
相关文章推荐
- iOS UILabel 显示带有html标签的富文本内容
- 转载 :ios UIWebView截获html并修改便签内容
- UITextView显示HTML内容,实现显示不同的字体和文字颜色
- ios UIWebView截获html并修改便签内容
- ios UIWebView截获html并修改便签内容
- iOS UILabel显示HTML文本
- IOS开发之——UIWebView截获html并修改便签内容
- IOS UIWebView截获html并修改便签内容,宽度自适应
- ios UIWebView截获html并修改便签内容以及用js对图片进行缩放
- iOS UIText 或 UILabel 显示 HTML 并正确选用编码
- UITextView 自适应高度 及显示html内容
- ios UIWebView截获html并修改便签内容
- ios UIWebView截获html并修改便签内容
- iOS UIWebView截获html并修改便签内容
- iphone开发之使用UIWebView显示html内容
- ios UIWebView截获html并修改便签内容
- ios UIWebView截获html并修改便签内容(转载)
- ios UIWebView截获html并修改便签内容
- 关于IOS中UIWebView 加载HTML内容
- iOS UILabel显示HTML文本