UIWebView 不适用于 file:///private/var/..../(myapp).app/www/index.html
UIWebView not work for file:///private/var/..../(myapp).app/www/index.html
当我使用下面的代码打开嵌入的 html 文件时。它不能触发委托:[
- 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];
我怎样才能得到这个请求?
它是您的本地计算机路径,而不是 simulator/iOS 路径。对于iOS,文件资源只有两个目录:
- NSBundle
- 文档目录
在你的例子中,你的 www 文件夹在 Bundle 文件夹中,所以试试这个:
NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"index" ofType:@"html" inDirectory:@"www"]];
当我使用下面的代码打开嵌入的 html 文件时。它不能触发委托:[ - 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];
我怎样才能得到这个请求?
它是您的本地计算机路径,而不是 simulator/iOS 路径。对于iOS,文件资源只有两个目录:
- NSBundle
- 文档目录
在你的例子中,你的 www 文件夹在 Bundle 文件夹中,所以试试这个:
NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"index" ofType:@"html" inDirectory:@"www"]];