0

我有一个RSS提要列表,我需要在 iPhone 中显示每个提要的详细信息。我RSS从服务器获得了所有提要,这些提要显示在 tableview 中。现在,在选择一行时,我需要在如下内容中显示RSS来自服务器的 Feed的描述HTML:-

<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\"/>

我如何HTML在我们的 iPhone 中显示此内容UI,因为这将包含文本、超链接和图像。

UIWebview在这种情况下使用它是否正确,UIWebView重量也是如此。

4

5 回答 5

1

请阅读此博客:http ://www.raywenderlich.com/2636/how-to-make-a-simple-rss-reader-iphone-app-tutorial ,对您很有用。

于 2013-05-27T09:51:40.090 回答
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;

 }

让我知道它是否有效..

编码快乐!!!!

于 2013-05-27T09:35:07.110 回答
0

如果您打算按HTML原样显示实体,我建议您使用UIWebView. HTML您可以在方法中将其作为字符串传递loadHTMLString:

于 2013-05-27T09:38:50.633 回答
0

如果您希望用户以网页形式查看内容,那么加载 urlUIWebView是最好和最简单的方法。像这样:

UIWebView *webView = [[UIWebView alloc] init];
NSURL *pageurl = [NSURL URLWithString:http://www.google.com];
NSURLRequest *request = [NSURLRequest requestWithURL:pageurl];
[webView loadRequest:request];
于 2013-05-27T10:08:59.317 回答
0

您可以简单地使用RSSKit库。

于 2013-05-27T10:38:55.567 回答