Loading a UIWebView from a UITableView -


i've come part of code i'm bit stumped, i'm trying load once tap example google in uitableview, load google separate view controller uiwebview. i've coded think right although when tap on google, nothing happens. i'm not getting errors, app runs fine it's said once tap selected field doesn't lead anywhere & before did remember import uiwebview controller first view controllers .m file.

this first view controller .h

@interface yomafifthviewcontroller : uitableviewcontroller  {  nsarray *data, *sites; }    @end 

this first view controller .m

- (void)viewdidload { [super viewdidload];  data = [nsarray arraywithobjects:@"website", @"developer", nil]; sites = [nsarray arraywithobjects:          @"https://www.google.co.uk/",          @"https://www.google.co.uk/",          nil]; 

`

- (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { static nsstring *cellidentifier = @"cell";  uitableviewcell *cell = [tableview dequeuereusablecellwithidentifier:cellidentifier]; if (cell == nil) {     cell = [[uitableviewcell alloc] initwithstyle:uitableviewcellstylesubtitle reuseidentifier:cellidentifier]; } 

`

 // configure cell...  cell.textlabel.text = [data objectatindex:indexpath.row]; cell.accessorytype = uitableviewcellaccessorydisclosureindicator; return cell; 

`

#pragma mark - table view delegate  - (void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath  { yomawebsiteviewcontroller *wvc = [[yomawebsiteviewcontroller alloc]     initwithnibname:@"yomawebsiteviewcontroller" bundle:nil]; wvc.site = [sites objectatindex:indexpath.row]; [self.navigationcontroller pushviewcontroller:wvc animated:yes];  } 

this uiwebviews .h

`

@interface yomawebsiteviewcontroller : uiviewcontroller {  iboutlet uiwebview *webview;  }  @property (retain) nsstring *site;   @end 

& uiwebviews .m

`

- (void)viewdidload { [super viewdidload];  nsurl *url = [nsurl urlwithstring:self.site]; nsurlrequest *request = [nsurlrequest requestwithurl:url]; [webview loadrequest:request]; 

my guess url getting set after viewdidload method being executed. regardless, it's not bad idea have loadurl method in setter (or public method re-load url , refresh webview).

-(void)setsite:(nsstring*)s {     _site = s;      if(webview) {         [self loadurl];     } }  - (void)viewdidload {     [super viewdidload];     if([self.site length] > 0) {         [self loadurl];     } }  -(void)loadurl {     nsurl *url = [nsurl urlwithstring:self.site];     nsurlrequest *request = [nsurlrequest requestwithurl:url];     [webview loadrequest:request]; } 

Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -