iPhone - 使用最近从互联网加载的页面覆盖现有 HTML 页面
以下是我的要求摘要
要求:
步骤:
注意:我已经有一个页面“abc.html”(但它可能包含过时的内容)
- 检查互联网连接
如果互联网连接不可用:
- 从资源文件夹(应用内)加载页面“abc.html”
如果互联网连接可用:
- 获取“abc.html”页面(位于网络服务器上)的链接
- 从网络服务器加载现有页面“abc.html”
- 同时将新的 abc.html(在网络服务器上)存储到应用中
- 通知用户并重新加载页面
- 使用从互联网下载的 HTML 页面更新“abc.html”
到目前为止我所做的:
- 我已经使用 Reachability 检查了互联网连接是否可用
- 此外,我还能够在 UIWebView 中显示现有的“abc.html”页面。
我正在寻找什么:
我想知道如何用刚刚加载到 UIwebView 中的页面(网络服务器上的页面)替换(覆盖/更新)这个现有的“abc.html”页面。
另外如果你有更好的方法来实现这个功能。请随时提出建议。
谢谢
编辑:
我想使用 ASIHTTPREquest 来实现这一点(ASI DataCache)...请指导
following is the summary of my requirement
Requirement :
Steps:
NOTE: I already have a page "abc.html" (but it may have outdated contents)
- check for internet connectivity
If the internet connection NOT is available:
- load the page "abc.html" from resource folder (inside app)
If the internet connection is available:
- get the link to the "abc.html" page (that is on webserver)
- load the existing page "abc.html" from web server
- meanwhile store the new abc.html (on web server) into the app
- notify the user and reload the page
- update the "abc.html" with the HTML page downloaded from Internet
What I have done till now:
- I have checked whether the internet connection is available using Reachability
- Also I am able to show the existing "abc.html" page in UIWebView.
What I am seeking:
I want to know How can I replace (overwrite/ update) this existing "abc.html" page with the one that is just loaded into UIwebView (the one on web-server).
Also If you have a better way to achieve this functionality . please feel free to suggest.
Thank you
EDIT:
I want to use ASIHTTPREquest to achieve this (ASI DataCache)... please guide
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有多种方法可以做到这一点,但你可以看看
NSURLCache
。如果您子类化
NSURLCache
,您就可以控制 Web 视图从cachedResponseForRequest:
方法中加载数据的位置。缓存还保存网页可能下载的所有图像,因此即使没有连接,您也可以提供完整的页面内容。
There are several ways to do this, but you could take a look at
NSURLCache
.If you subclass
NSURLCache
, you get to control where the web view will load its data from in thecachedResponseForRequest:
method.The cache also holds any images the web page might download, so you can provide the full page content, even without a connection.