UIWebView 网页缓存以供离线查看 [英] UIWebView webpage caching for offline viewing

查看:20
本文介绍了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).

还有几个答案,但没有一个是好的.我正在搜索的内容必须有一些简单的实现.

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

我想:当应用程序打开时,它会加载一些网页.我想完全保存该网页.现在用户可以退出或做任何他想做的事(只是不卸载).只要有一些互联网连接(我使用可达性类检查),网页就会正常加载并被保存.如果用户打开应用程序并且没有互联网连接,我只想显示它可能不是最新的 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 创建自己的缓存机制.您可以在 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天全站免登陆