1

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?

Jayyrus
  • 12,961
  • 41
  • 132
  • 214
  • Can you add the tags that are being used to include the CSS and JS? Are you loading jquery from the remote server with a relative URL or from a CDN? – smparkes Feb 24 '12 at 23:56

2 Answers2

1

The problem is that the webview doesn't have the right path from which to handle the CSS link. Look at

– loadHTMLString:baseURL:

and

– loadData:MIMEType:textEncodingName:baseURL:

on UIWebView. You'd want to give the baseURL as 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.

smparkes
  • 13,807
  • 4
  • 36
  • 61
1

JackTurky, in a fast search in google, i found this.

I Hope that this is going to help you.

Community
  • 1
  • 1
  • Maybe help: http://stackoverflow.com/questions/792585/jquery-not-loading-on-the-iphone –  Feb 24 '12 at 23:57