在Web View中加载html数据?

时间:2015-01-22 13:04:02

标签: html ios uiwebview

<p>kick 2 first look on republic day According to the latest update, the first look of the film Kick 2 will be released on 26th of January. Regular shooting of this film is going on at a brisk pace in Hyderabad. Rakul Preet is playing the female lead in this film and Thaman is scoring ...</p>
<p>The post <a rel="nofollow" href="http://www.teluguabroad.com/kick-2-first-look-republic-day/">kick 2 first look on republic day</a> appeared first on <a rel="nofollow" href="http://www.teluguabroad.com">Teluguabroad</a>.</p>

如何在网页视图中显示这个,我是从rss Feed获取的?在具有Web视图的下一个视图控制器中显示该内容?

1 个答案:

答案 0 :(得分:0)

您需要设置一个html字符串,然后您可以在Web视图上加载它。

    NSString *rssString=[NSString stringWithFormat:@"<p>kick 2 first look on republic day According to the latest update, the first look of the film Kick 2 will be released on 26th of January. Regular shooting of this film is going on at a brisk pace in Hyderabad. Rakul Preet is playing the female lead in this film and Thaman is scoring ...</p><p>The post <a rel=\"nofollow\" href=\"http://www.teluguabroad.com/kick-2-first-look-republic-day/\">kick 2 first look on republic day</a> appeared first on <a rel=\"nofollow\" href=\"http://www.teluguabroad.com\">Teluguabroad</a>.</p>"];
NSString *myHTML = [NSString stringWithFormat:@"<html><body>%@</body></html>",rssString];
[myUIWebView loadHTMLString:myHTML baseURL:nil];

另请注意每个双引号&#34;我们在NSString中使用了一个斜杠&#39; \#39;。因此,Xcode编译器可以理解这些双引号是字符串的一部分,并且不会将NSString与@&#34; &#34;我们在Xcode中使用的标识符。

如果您需要将其加载到下一个视图控制器,您可以使用属性并在Web视图上加载将字符串myHTMl发送到下一个视图控制器。