2010-06-21 134 views
0

我尝试过许多方法,在许多线程中指定。仍然我的WebView不加载本地js文件。 ,我已经试过UIWebView加载本地文件

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]; 

但没有网页视图工作的方式。任何人都可以帮我解决这个问题吗?

回答

0

确保Javascript文件正被复制到资源包。当您将.js文件添加到Xcode时,它会尝试默认编译它们,而不是将它们复制到资源束。详情请参阅jQuery not loading on the iPhone