2

When I using code below to open an embedded html file. it cannot trigger the delegate : [ - webView:shouldStartLoadWithRequest:navigationType:];

NSURL *url = [NSURL URLWithString:@"file:///private/var/..../(myapp).app/www/index.html"];

NSMutableURLRequest *urlReq = [NSMutableURLRequest requestWith:url
                              cachePolicy:NSURLRequestUseProtocolCachePolicy 
                              timeoutInterval: 60.0f];

[webview loadRequest:urlReq];

How can I get this request?

Ericpoon
  • 267
  • 1
  • 2
  • 11

1 Answers1

0

Its your local machine path, not the simulator/iOS path. For iOS, there are only two directories for file resources:

  • NSBundle
  • Document directory

In your case, your www folder is in Bundle folder so, try this:

NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"index" ofType:@"html" inDirectory:@"www"]];
Mrunal
  • 13,982
  • 6
  • 52
  • 96
  • the path is come from NSBundle class, the actual path point to myapp.app/www/ . It's only not work from iOS8. – Ericpoon Jul 21 '15 at 15:20