I made an hybrid app between objective C and javascript. My app works so:
- When I press on the first button it will load a UIWebView
- In this UIWebView I can save the html to the Documents folder
- When I save the website I create a JSON to store informations and I save this JSON to Documents folder
- When I press the second button, it will load another UIWebView in which there are a mobile site that read informations from JSON and present this data in a html list
- When I press on the name of one site it will load the site from Documents folder
The first 4 points works great, but when I press on the site title I've trouble, indeed, the UIWebView shows me a page in which there are written that the page it's not stored on this server. When I navigate with Finder to the Documents folder of my app and I double click on the html site it shows me it in Safari. Why when I load it with an UIWebView doesn't work? I will post here a screenshot to understand my flow.
CODE: I post here the code to load the html:
viewDidLoad method where I call the method to load my page
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
self.webView.delegate = self;
//[self loadWebsite:@"http://localhost/root/main/index.html"];
[self loadWebsite:@"http://192.168.2.1/root/main/index.html"];
}
loadWebsite method
-(void)loadWebsite:(NSString*)site
{
NSURL *url = [NSURL URLWithString:site];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[self.webView setScalesPageToFit:YES];
[self.webView loadRequest:request];
}