i’m creating an app in which i have a uiwebview.
I want to load a page saved in local using:
[web loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"index" ofType:@"html"]isDirectory:NO]]];
the problem is that css isn’t correctly loaded so page will be shown incorrectly.
This page is still in remote ( i wanto to remove it from there ), so i try to load remote page:
NSString *strIndirizzo = @"foo.com";
NSURL *url = [NSURL URLWithString:strIndirizzo];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[web loadRequest:request];
[web setScalesPageToFit:YES];
And it is correctly loaded. Where could be the problem? can you help me?
EDIT:
Solved CSS.. i don’t know why css is loaded only outside the folder where it was. Now the problem concerns about jquery :/ i’m using jqtouch in remote page and it doesn’t work in UiwebView local :/ anyone?
The problem is that the webview doesn’t have the right path from which to handle the CSS link. Look at
and
on
UIWebView. You’d want to give thebaseURLas the place you saved the data.Note this generally won’t work if the CSS link uses an absolute path (starting with “/”) or if you the HTML or CSS are not in the same directory.