In particular, I have a folder structure that looks like this:
- about (main folder)
- css (this subfolder contains css files)
- img (this subfolder contains img files)
- js (this subfolder contains js files)
- (this subfolder contains the index.html file)
If I click on the index.html file from a normal browser, everything will work as expected.
However, I am trying to load this index.html into a UIWebView .
So far, what I have done, I dragged the "about" folder in Xcode and copied it there, like any other file. Then I tried the following code:
NSString *htmlFile = [[NSBundle mainBundle] pathForResource:@"index" ofType:@"html"]; NSData *htmlData = [NSData dataWithContentsOfFile:htmlFile]; NSURL *baseURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] resourcePath]]; [webView loadData:htmlData MIMEType:@"text/html" textEncodingName:@"UTF-8" baseURL:baseURL];
The webview loads index.html, however it does not load the images / css / js as I believe that it cannot find them in the folder structure.
Any help would be appreciated! Thanks!
source share