iOS离线网络应用程序 - 进度条?

时间:2013-08-21 20:44:16

标签: web-applications iphone-standalone-web-app iphone-web-app

我正在创建一个离线网络应用,看起来大约只有1.5MB。

当用户为我的应用添加书签时,是否仍然检查清单中的所有脱机文件是否已下载?或者更好的是,像这样的进度条是iTunes App下载。

1.5MB可能是安全的,但是假设我创建了一个50MB的离线网络应用程序,并且用户在没有3G服务的iPad上使用Wi-Fi时为网络应用添加了书签。他们给它添加了书签然后立即离开了Wi-Fi区域,他们(或者我知道)他们将如何在本地缓存/存储所有文件?

1 个答案:

答案 0 :(得分:2)

使用appCache事件监听器

function handleCacheEvent(e) {
  // Do your thing
}

function handleCacheError(e) {
  alert('Error: Cache failed to update!');
};

// Fired after the first cache of the manifest.
appCache.addEventListener('cached', handleCacheEvent, false);

// Checking for an update. Always the first event fired in the sequence.
appCache.addEventListener('checking', handleCacheEvent, false);

// An update was found. The browser is fetching resources.
appCache.addEventListener('downloading', handleCacheEvent, false);

// The manifest returns 404 or 410, the download failed,
// or the manifest changed while the download was in progress.
appCache.addEventListener('error', handleCacheError, false);

// Fired after the first download of the manifest.
appCache.addEventListener('noupdate', handleCacheEvent, false);

// Fired if the manifest file returns a 404 or 410.
// This results in the application cache being deleted.
appCache.addEventListener('obsolete', handleCacheEvent, false);

// Fired for each resource listed in the manifest as it is being fetched.
appCache.addEventListener('progress', handleCacheEvent, false);

// Fired when the manifest resources have been newly redownloaded.
appCache.addEventListener('updateready', handleCacheEvent, false);
相关问题