In particular, how do you get all the resources to download from your respective directories (images /, css /, js /) without changing the contents of the original HTML (deleting directories)?
I use this code to load index.html in a UIWebview:
NSURL *url = [[NSBundle mainBundle] URLForResource:@"index" withExtension:@"html"]; NSString *html = [NSString stringWithContentsOfURL:url encoding:NSUTF8StringEncoding error:nil]; NSString *path = [[NSBundle mainBundle] bundlePath]; NSURL *baseURL = [NSURL fileURLWithPath:path]; [webView loadHTMLString:html baseURL:baseURL];
Then my html looks like this:
... <link rel="stylesheet" type="text/css" href="css/main.css" /> <script type="text/javascript" src="js/classes.js"></script> <script type="text/javascript" src="js/animate.js"></script> etc...
If I remove js /, css / and images /, everything works because iOS believes that everything is at the root of my package. But this means that I cannot use the same code for projects without dumping all of it into one directory (llama). The engineer in me cannot handle this disorganization.
Thanks in advance.
source share