2010-06-21 188 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