ios - I need to format and display specified contents from the URL in webView -
i creating rss feed app , need format feeds in webview , display description .
here code:
- (void)viewdidload { [super viewdidload]; nsurl *myurl = [nsurl urlwithstring: [self.url stringbyaddingpercentescapesusingencoding: nsutf8stringencoding]]; nsurlrequest *request = [nsurlrequest requestwithurl:myurl]; [self.webview loadrequest:request]; }
instead of loading contents of specified url need format , display "description" of rss feed. have parsed data need format in web view . code parsing (prepareforsegue):
- (void)prepareforsegue:(uistoryboardsegue *)segue sender:(id)sender { if ([[segue identifier] isequaltostring:@"showdetail"]) { nsindexpath *indexpath = [self.tableview indexpathforselectedrow]; nsstring *string = [feeds[indexpath.row] objectforkey: @"link"]; nslog(@"description : %@" , string); [[segue destinationviewcontroller] seturl:string]; } }
from question seems require parse response first.
nsurl *url = [nsurl urlwithstring:@"http://www.google.co.in/search?q=search"]; nsstring *webdata= [nsstring stringwithcontentsofurl:url]; nslog(@"%@",webdata);
this code store html page nsstring after getting this, parse string same normal xml parsing using html tags , required data out of this.
here code load string uiwebview in html format:
if literally want load html string, try this:
nsstring *embedhtml = @"<html><head></head><body><p>provide display data here in html format</p></body></html>"; // in case description data [webview loadhtmlstring: embedhtml baseurl: nil];
hope looking for.
Comments
Post a Comment