【问题标题】:UIWebView loading local filesUIWebView 加载本地文件
【发布时间】:2010-06-21 05:42:33
【问题描述】:

我已经尝试了许多线程中指定的许多方法。我的 WebView 仍然没有加载本地 js 文件。 我尝试过的方式

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

但网络视图不起作用。谁能帮我解决这个问题?

【问题讨论】:

    标签: iphone uiwebview


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-01-02
      • 2011-06-06
      • 2013-01-18
      • 2012-12-08
      相关资源
      最近更新 更多