How to save the content in UIWebView for faster loading on next launch?

前端 未结 5 838
臣服心动
臣服心动 2020-11-29 00:14

I know that there are some caching classes introduced in the iphone sdk recently, and there is also a TTURLRequest from three20\'s library that allows you to cache a request

5条回答
  •  渐次进展
    2020-11-29 00:35

    You can save an HTML in the documents directory and load the page directly from the documents directory on launch.

    To save the webview content: Reading HTML content from a UIWebView

    To load:

        NSString* path = [[NSBundle mainBundle] pathForResource:@"about" ofType:@"html"];
        NSURL* url = [NSURL fileURLWithPath:path];
    
        NSURLRequest* request = [NSURLRequest requestWithURL:url];
        [webView loadRequest:request];
    

提交回复
热议问题