Iphone UIWebView加载本地文件
我尝试了许多线程中指定的方法。我的WebView仍然没有加载本地js文件。 我试过的方法Iphone UIWebView加载本地文件,iphone,uiwebview,Iphone,Uiwebview,我尝试了许多线程中指定的方法。我的WebView仍然没有加载本地js文件。 我试过的方法 NSString *tempResourcePath=[[NSBundle mainBundle] resourcePath]; NSURL *resourceUrl = [NSURL fileURLWithPath:tempResourcePath]; [webView loadHTMLString:html baseURL:resourceUrl]; NSString *html = [[NSStr
NSString *tempResourcePath=[[NSBundle mainBundle] resourcePath];
NSURL *resourceUrl = [NSURL fileURLWithPath:tempResourcePath];
[webView loadHTMLString:html baseURL:resourceUrl];
NSString *html = [[NSString alloc] initWithContentsOfFile:htmlPath];
NSString *resourcePath = [[NSBundle mainBundle] resourcePath];
//resourcePath = [resourcePath stringByReplacingOccurrencesOfString:@"/" withString:@"//"];
resourcePath = [resourcePath stringByReplacingOccurrencesOfString:@" " withString:@"%20"];
resourcePath = [NSString stringWithFormat:@"file:/%@/",resourcePath];
NSURL *resourceUrl = [NSURL fileURLWithPath: resourcePath];
但是webview不起作用。有人能帮我解决这个问题吗?确保Javascript文件被复制到资源包中。当您将.js文件添加到Xcode时,默认情况下它会尝试编译它们,而不是将它们复制到资源包中。有关详细信息,请参阅