用于离线查看的UIWebView网页缓存 [英] UIWebView webpage caching for offline viewing

查看:106
本文介绍了用于离线查看的UIWebView网页缓存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,我很确定我已经检查过这里的每一个答案,而我想做什么也没有。

First of all, I'm pretty sure that I have checked every answer here and nothing does what I would like to do.


  1. 在这个问题中,答案是ASIHTTPRequest,这是死项目。 (如何下载整个网页(有图像)在iPhone上?

  2. 在这个问题中,用户提出了RNCachingURLProtocol这真的很棒,但在完全关闭应用程序后我遇到了一些问题(在任务中关闭它) -酒吧)。之后我没有得到CSS或图像,只加载了html。 (缓存单个网页,以便在离线时使用Xcode / UIWEBVIEW )。

  1. In this question, for answer is given ASIHTTPRequest which is dead project. (How do I download an entire webpage (with images) on the iPhone?)
  2. In this question, user proposed RNCachingURLProtocol which is really great but I had a few problems after closing app completely (closing it in task-bar). After that I didn't get css or images, only html was loaded. (Cache a single webpage for use when offline in Xcode / UIWEBVIEW).

还有更多的答案,但没有一个是好的。对于我正在搜索的内容,必须有一些简单的实现。

There are few more answers but none is good. There must be some simple implementation for what I'm searching.

我想:当应用程序打开时,它会加载一些网页。我想完全保存该网页。现在用户可以退出或做任何他想做的事情(只是不卸载)。只要有一些互联网连接(我检查使用可达性类),网页正常加载并保存。如果用户打开应用程序并且没有INTERNET连接我只想显示消息它可能不是最新的bla bla boa并显示上次应用程序有互联网连接时保存的完整,保存的网页。

I would like to: When app opens, it loads some webpage. I want to save that webpage completely. Now user can quit or do whatever he wants (just not uninstall). As long as there is some internet connection (I check that using reachability class), webpage loads normally and it's being saved. IF USER opens app and there is NO INTERNET connection I just want to show message that "it might not be up to date bla bla boa" and show complete, saved webpage that was saved last time application has internet connection.

保存完整网页的最佳方法(最新)。我发现了一些关于MKNetworkKit但我不确定如何使用它。任何帮助将不胜感激。

What would be the best way (up to date) to save complete webpage. I'v found something about MKNetworkKit but I'm not sure how to use that. Any help would be appreciated.

推荐答案

听起来标准缓存不够好,因为你无法控制将会是什么缓存和持续多久。解决这个问题的最简单方法是通过覆盖NSURLCache来创建自己的缓存meganism。您可以在 http://nshipster.com/nsurlcache/ 找到一些相关文档,并在 http://github.com/evermeer/EVURLCache 该示例甚至允许您使用可以包含的预先填充的缓存在您的应用安装中。

It sounds like the standard caching is not good enough because you have no control over what will be cached and for how long. The easiest way for solving this is by creating your own caching meganism by overriding the NSURLCache. You can find some documentation about that at http://nshipster.com/nsurlcache/ and a sample at http://github.com/evermeer/EVURLCache That sample even let you use a pre populated cache that can be included in your app install.

这篇关于用于离线查看的UIWebView网页缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆