在iOS应用程序中为UIWebView预填充HTML5离线appcache [英] Pre-populate HTML5 offline appcache for a UIWebView in an iOS application

查看:132
本文介绍了在iOS应用程序中为UIWebView预填充HTML5离线appcache的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以创建一个预先填充了HTML5离线appcache的UIWebView,以便即使是第一次用户访问UIWebView也能脱机工作?

Is it possible to create a UIWebView that has an HTML5 offline appcache pre-populated so that it will work offline even if it is the first time the user is accessing the UIWebView?

如果是这样,怎么样?

我知道我可以通过其他机制实现这一点,但以上是我的第一选择。如果可能的话,我只是很好奇。

I know I can achieve this through other mechanisms, but the above is my first choice. And I'm just plain curious if it's possible.

我在文档中没有看到它。

I'm seeing nothing about it in the documentation.

推荐答案

我认为这可能会减少一个问题,即您是否可以以编程方式写入UIWebView的缓存文件(也就是说,UIWebView缓存是否位于应用程序的沙箱中) - 如果您不能,然后游戏结束。如果您可以,那么在您将预先填充的缓存文件放入适当位置后会出现什么问题,以及UIWebView是否被欺骗以认为已经下载并缓存了您的HTML5内容。

I think this may reduce to a question of whether you can programmatically write to the UIWebView's cache file (which is to say, whether the UIWebView cache resides within your app's sandbox) – if you can't, then game over. If you can, then it becomes a question of what happens after you drop a pre-populated cache file into place, and whether the UIWebView is "fooled" into thinking that it's already downloaded and cached your HTML5 content.

如果您正在使用iPhone模拟器测试您的应用,请查看〜/ Library / Application Support / iPhone Simulator / 5.0 / Applications (如果需要,请将iOS 5.0替换为5.0)。您应该在模拟器中为每个应用程序看到一个长十六进制数字字符串;找到与您的应用程序对应的那个,然后在 Library / Caches / [您的应用程序标识符] 子文件夹中查找名为 Cache.db的文件

If you're using the iPhone Simulator to test your app, look in ~/Library/Application Support/iPhone Simulator/5.0/Applications (replace "5.0" with your iOS version, if necessary). You should see a long string of hex digits for each app you've compiled in the simulator; find the one that corresponds to your app, and then look in the Library/Caches/[your app's identifier] subfolder for a file named Cache.db.

可能是UIWebView存储其缓存数据的地方。如果不是,游戏结束,你的问题的答案是不,那是不可能的。如果,其中UIWebView缓存数据,则可能可以在模拟器中填充此 Cache.db 文件,抓取文件,将其存储在您的应用程序包中,然后在预先填充缓存时将缓存写入适当的位置。

This may be the place where UIWebView stores its cache data. If it isn't, game over and the answer to your question is "no, that's not possible". If it is where UIWebView caches data, then it may be possible to populate this Cache.db file in the simulator, grab the file, store it in your app bundle, and then write the cache to the appropriate location when it's time to pre-populate the cache.

无论如何,这是我用来确定它是否可能的攻击线 - 我非常有信心答案是不,不可能,除非事实证明UIWebView缓存 驻留在你的app的沙箱,你可以写,你可以通过替换它的缓存文件来欺骗UIWebView。

At any rate, that's the line of attack I'd use to determine whether it's possible – I'm pretty confident the answer is going to be "no, not possible" unless it turns out the UIWebView cache does reside in your app's sandbox, is writable by you, and you can fool UIWebView by replacing its cache file.

这篇关于在iOS应用程序中为UIWebView预填充HTML5离线appcache的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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