am trying to add a UIWebView to my current UIScrollView. The UIWebView is supposed to access a local html file ‘index.html’. I got an error at runtime:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSURL initFileURLWithPath:]: nil string parameter'
This is my code:
UIWebView *webView = [[UIWebView alloc] initWithFrame:scrollViewFrame];
NSString *indexPath = [NSBundle pathForResource:@"index" ofType:@"html" inDirectory:@"Addition"];
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:indexPath]]];
I do have ‘Addition’ folder (not group; imported from ‘Add’ in my project).
Thanx in advance…
Did you check
indexPathwith a breakpoint orNSLog? It looks like your file is not there (perhaps a typo?)-EDIT
OK, I just tested this successfully. Try this:
One more caveat: Maybe there is a difference in capitalized resource names between the simulator and the device. Try using lowercase throughout.
Also, you should perhaps correct your command pulling the resource from the bundle. Instead of
it should be