Why would i ever want to load a local file to a UIWebView….i can think of many, but let’s get down to the code. Don’t make the mistake i made. You need to remember the file is local not in the cloud….so in one method, i will sum it up:
-(void)viewWillAppear:(BOOL)animate { _webview = [[UIWebView alloc] initWithFrame:self.view.bounds]; _webview.delegate = self; NSString *bundlepath = [[NSBundle mainBundle] pathForResource:@"page_1" ofType:@"html"]; //[_webview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:bundlepath]]]; [_webview loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:bundlepath]]]; [self.view addSubview:_webview]; }
the commented line was the mistake….this is a “file with a path” , local to the device…not a true “url”….that fix, solves the problem