Webview displaying one HTML file in iPhone sdk -


i have 3 html files in local resources bundle. need display reader. used web view display using following code,

- (void)viewdidload {      [super viewdidload];      totalarray=[[nsmutablearray alloc]init];      [totalarray addobject:@"file1"]; [totalarray addobject:@"file2"]; [totalarray addobject:@"file3"];     nslog(@"totalarray count:%d",[totalarray count]);      (int i=0;i<3;i++) {     nslog(@"i count:%d",i);     nsstring *bundlepath = [[nsbundle mainbundle] bundlepath];        nsurl *bundlebaseurl = [nsurl fileurlwithpath: bundlepath];        nslog(@"webview %@", bundlepath);    nsstring *filepath1= [[nsbundle mainbundle] pathforresource:[totalarray objectatindex:i] oftype:@"html"];        nslog(@"filepath1:%@",filepath1);        [htmlview loadrequest:[nsurlrequest requestwithurl:[nsurl urlwithstring:filepath1]]];     } } 

am getting total count 3, current index counts , file path. still displays first html file. other 2 files missing. problem here? kindly me. thanking you.

you need wait till file loaded , looping not god idea , instead can achieve same using below code. use fileurlwithpath load local file.

- (void)viewdidload {     [super viewdidload];     count = 0;     totalarray=[[nsmutablearray alloc]init];     [totalarray addobject:@"file1"];     [totalarray addobject:@"file2"];     [totalarray addobject:@"file3"];           [_htmlview setdelegate:self];     nsstring *filepath1= [[nsbundle mainbundle] pathforresource:[totalarray objectatindex:count] oftype:@"html"];     nsurl *url = [nsurl fileurlwithpath:filepath1];     [_htmlview loadrequest:[nsurlrequest requestwithurl:url]];  }  - (void)webviewdidfinishload:(uiwebview *)webview{     count++;     if (count < 3) {          nsstring *filepath1= [[nsbundle mainbundle] pathforresource:[totalarray objectatindex:count]                                                              oftype:@"html"];         nslog(@"filepath1:%@",filepath1);         nsurl *url = [nsurl fileurlwithpath:filepath1];         [_htmlview loadrequest:[nsurlrequest requestwithurl:url]];     }  } 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -