1
私は常に次のコードを使用してのUIWebViewの最新のキャッシュされたコピーを持っていることを確認しようとしている:私は終了せずに機内モードに行くとき、それは以外、ほとんどの場合、正常に動作しますUIWebViewキャッシュを取得していますか?
// Set URL to help file on server
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@", HELP_FILE_URL]];
// Check network reachability
wifiReach = [Reachability reachabilityWithHostName:[NSString stringWithFormat:@"%@", SERVER_URL]];
netStatus = [wifiReach currentReachabilityStatus];
// Start activity indicators
[self startAnimation];
// Verify current help file cache if we have network connection...
if (netStatus == ReachableViaWWAN || netStatus == ReachableViaWiFi) {
helpFileRequest = [NSURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadRevalidatingCacheData timeoutInterval:30];
} else {
// Network NOT reachable - show (local) cache if it exists
helpFileRequest = [NSURLRequest requestWithURL:url cachePolicy:NSURLRequestReturnCacheDataDontLoad timeoutInterval:30];
}
// Show help file in a web view
[webView loadRequest:helpFileRequest];
をアプリ。一度機内モードにキャッシュされたのWebViewは罰金示すが、のUIWebViewデリゲート
(void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
でも、私はしたくないいるトリガされます。キャッシュが空の場合にのみトリガーされるようにしたい!それをどうすれば実現できますか? (私がアプリを終了するとうまくいきます。)細かいことですが、実際には正しく動作します:)