无论如何在textview中显示HTML内容? [英] is there anyway to display HTML content in textview?

查看:84
本文介绍了无论如何在textview中显示HTML内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试了以下一个来自iphone cook book .i通过访问UITextview的私有API显示HTML内容,如

i tried the following one from iphone cook book .i displayed HTML content through accessing private API of UITextview like

 @interface UITextView (extended)
 - (void)setContentToHTMLString:(NSString *) contentText;
 @end

它有效 FINE 。但Apple不允许访问私有API.any解决方案?

it works FINE.but Apple wont allow accessing private API.any solution pls?

推荐答案

是否要显示实际的HTML元素或仅显示您从网上取下的字符串?对于后者,您将执行以下操作:

Do you want to display actual HTML elements or just a string you took off the web? For the latter, you would do the following:

NSURL *stringURL = [NSURL URLWithString:@"http://yoursite.com/page.html"];
NSString *responseString = [NSString stringWithContentsOfURL:stringURL encoding: NSUTF8StringEncoding error:nil];
myTextView.text = responseString;

这篇关于无论如何在textview中显示HTML内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆