iPhone UIWebView slow loading to local HTML files

前端 未结 7 1463
无人及你
无人及你 2021-02-01 03:47

I\'m developing an app that requires caching web pages (completely) along with their CSS files and images after saving the entire HTML of the page (going through the links to st

相关标签:
7条回答
  • 2021-02-01 04:40

    Even in my case, while loading local html files to webview was taking too much time.

    Try to load local html files as below, it worked for me:

    NSString *htmlFile = [[NSBundle mainBundle] pathForResource:@"website_and_mobile_tnc-1" ofType:@"html"];
    NSString* htmlString = [NSString stringWithContentsOfFile:htmlFile encoding:NSUTF8StringEncoding error:nil]; 
    [_TandCView loadHTMLString:[headerString stringByAppendingString:htmlString] baseURL:nil];
    

    If you want to load using NSData, try to make baseUrl to "nil" in your code.

    I have modified your code as below,

        NSData *htmlData = [NSData dataWithContentsOfFile:htmlFilePath];
      [wView loadData:htmlData MIMEType:@"text/html" textEncodingName:@"UTF-8" baseURL:nil];
    

    I didn't tried this, but please try and let me know.

    0 讨论(0)
提交回复
热议问题