iPhone - 使用最近从互联网加载的页面覆盖现有 HTML 页面

发布于 2024-11-18 19:04:15 字数 763 浏览 9 评论 0原文

以下是我的要求摘要

要求:

步骤:

注意:我已经有一个页面“abc.html”(但它可能包含过时的内容)

  1. 检查互联网连接
  2. 如果互联网连接不可用:

    1. 从资源文件夹(应用内)加载页面“abc.html”

    如果互联网连接可用:

    1. 获取“abc.html”页面(位于网络服务器上)的链接
    2. 从网络服务器加载现有页面“abc.html”
    3. 同时将新的 abc.html(在网络服务器上)存储到应用中
    4. 通知用户并重新加载页面
    5. 使用从互联网下载的 HTML 页面更新“abc.html”

到目前为止我所做的:

  1. 我已经使用 Reachability 检查了互联网连接是否可用
  2. 此外,我还能够在 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)

  1. check for internet connectivity
  2. If the internet connection NOT is available:

    1. load the page "abc.html" from resource folder (inside app)

    If the internet connection is available:

    1. get the link to the "abc.html" page (that is on webserver)
    2. load the existing page "abc.html" from web server
    3. meanwhile store the new abc.html (on web server) into the app
    4. notify the user and reload the page
    5. update the "abc.html" with the HTML page downloaded from Internet

What I have done till now:

  1. I have checked whether the internet connection is available using Reachability
  2. 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夜唯美灬不弃 2024-11-25 19:04:15

有多种方法可以做到这一点,但你可以看看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 the cachedResponseForRequest: method.
The cache also holds any images the web page might download, so you can provide the full page content, even without a connection.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文