I am caching HTML contents of UIWebView in a string and trying it to load back when application is offline
if ([hostReach hostConnectionStatus] == NotReachable) { NSString *cachedResponse = [[NSString alloc] initWithData:[self responseHTMLData] encoding:NSNEXTSTEPStringEncoding]; [webView loadHTMLString:cachedResponse baseURL:final_url]; }
cachedResponse is an HTML data in it but the problem is UIWebView fails to load this data
// WebView Delegate - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType { return YES; } - (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error { // error description "connection is offline" }
How to I load HTML contents in UIWebVIew when its offline
final_url
. All resources referenced in the HTML file must be cached as well, andfinal_url
needs to be a path to those cached resources. – user3386109