我有RSS
个Feed列表,我需要在iPhone中显示每个Feed的详细信息。我从服务器上获得了所有RSS
个Feed,我正在tableview中显示。现在,在选择一行时,我需要在RSS
内容中显示来自服务器的HTML
Feed的说明,如: -
<a href=\"http://timesofindia.indiatimes.com/articleshow/4881843.cms\"><img border=\"0\" hspace=\"10\" align=\"left\" style=\"margin-top:3px;margin-right:5px;\" src=\"http://timesofindia.indiatimes.com/photo/4881843.cms\" /></a>Cadila Pharmaceutical will seek the govt's nod in two days for initiating clinical trials for a vaccine against swine flu.<img width='1' height='1' src='http://timesofindia.feedsportal.com/c/33039/f/533968/s/1f181b11/mf.gif' border='0'/><div class='mf-viral'><table border='0'><tr><td valign='middle'><a href=\"http://share.feedsportal.com/viral/sendEmail.cfm?lang=en&title=Cadila+to+apply+for+clinical+trials+for+swine+flu+vaccine&link=http%3A%2F%2Ftimesofindia.indiatimes.com%2Farticleshow%2F4881843.cms\" target=\"_blank\"><img src=\"http://res3.feedsportal.com/images/emailthis2.gif\" border=\"0\" /></a></td><td valign='middle'><a href=\"http://res.feedsportal.com/viral/bookmark.cfm?title=Cadila+to+apply+for+clinical+trials+for+swine+flu+vaccine&link=http%3A%2F%2Ftimesofindia.indiatimes.com%2Farticleshow%2F4881843.cms\" target=\"_blank\"><img src=\"http://res3.feedsportal.com/images/bookmark.gif\" border=\"0\" /></a></td></tr></table></div><br/><br/><a href=\"http://da.feedsportal.com/r/133515347892/u/0/f/533968/c/33039/s/1f181b11/a2.htm\"><img src=\"http://da.feedsportal.com/r/133515347892/u/0/f/533968/c/33039/s/1f181b11/a2.img\" border=\"0\"/></a><img width=\"1\" height=\"1\" src=\"http://pi.feedsportal.com/r/133515347892/u/0/f/533968/c/33039/s/1f181b11/a2t.img\" border=\"0\"/>
如何在我们的iPhone HTML
中显示此UI
内容,因为这将包含文字,超链接和图片。
在这种情况下使用UIWebview
是否正确,因为UIWebView
是重量级的。
答案 0 :(得分:1)
请阅读此博客: http://www.raywenderlich.com/2636/how-to-make-a-simple-rss-reader-iphone-app-tutorial , 它对你有用。
答案 1 :(得分:0)
你可以做类似下面的事情。
首先
descLbl.text=[self flattenHTML:descLbl.text];//descLbl.text is a text in which you are getting that HTML description...
现在在flattenHTML方法中编写如下...
- (NSString *)flattenHTML:(NSString *)html {
NSScanner *thescanner;
NSString *text = nil;
thescanner = [NSScanner scannerWithString:html];
while ([thescanner isAtEnd] == NO) {
[thescanner scanUpToString:@"<" intoString:NULL];
// find end of tag
[thescanner scanUpToString:@">" intoString:&text];
html = [html stringByReplacingOccurrencesOfString:[NSString stringWithFormat:@"\n"] withString:@" "];
// replace the found tag with a space
//(you can filter multi-spaces out later if you wish)
html = [html stringByReplacingOccurrencesOfString:[NSString stringWithFormat:@"%@>", text] withString:@" "];
} // while //
return html;
}
让我知道它是否正常工作..
快乐编码!!!!
答案 2 :(得分:0)
如果您打算按原样显示HTML
个实体,我建议您使用UIWebView
。您可以在方法HTML
loadHTMLString:
作为字符串传递
答案 3 :(得分:0)
如果您希望用户将内容视为网页,则在UIWebView
中加载网址是最简单最方便的方式。
像这样:
UIWebView *webView = [[UIWebView alloc] init];
NSURL *pageurl = [NSURL URLWithString:http://www.google.com];
NSURLRequest *request = [NSURLRequest requestWithURL:pageurl];
[webView loadRequest:request];
答案 4 :(得分:0)
您只需使用RSSKit库。