UIWebView webpage caching for offline viewing(UIWebView 网页缓存以供离线查看)
问题描述
首先,我很确定我已经检查了这里的每一个答案,没有做我想做的事情.
First of all, I'm pretty sure that I have checked every answer here and nothing does what I would like to do.
- 在这个问题中,给出的答案是 ASIHTTPRequest,这是一个死项目.(如何下载整个网页(带图片)在 iPhone 上?)
- 在这个问题中,用户提出了 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 网页缓存以供离线查看的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:UIWebView 网页缓存以供离线查看
基础教程推荐
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- android 应用程序已发布,但在 google play 中找不到 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- Android:对话框关闭而不调用关闭 2022-01-01
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01