问题
here i am trying for a application, when i click on the table view it will redirect to another page called details. there I have used a webview to dispaly the selected url value. here is my code
-(void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:YES];
self.navigationItem.title=@"sample";
servicesArray=[[NSMutableArray alloc]init];
[servicesArray addObject:@"1"];
[servicesArray addObject:@"2"];
[servicesArray addObject:@"3"];
urlsArray=[[NSMutableArray alloc]init];
[urlsArray addObject:@"http://www.google.com"];
[urlsArray addObject:@"http://www.yahoo.com"];
[urlsArray addObject:@"http://www.facebook.com"];
}
here instead of urls link i want to pass my local html files. can you please help me out
Thanks chintu.
回答1:
try like this,take all the html file names in Array yourArray.
NSString *htmlFile = [[NSBundle mainBundle] pathForResource:[yourArray objectAtIndex:selectedIndex] ofType:@"html" inDirectory:nil];
NSString* htmlString = [NSString stringWithContentsOfFile:htmlFile encoding:NSUTF8StringEncoding error:nil];
[WebView loadHTMLString:htmlString baseURL:nil];
来源:https://stackoverflow.com/questions/17422630/how-to-pass-local-html-files-using-array-in-xcode