UIWebView : do not use internet

141 Views Asked by At

I save a webpage into a NSData object which is stored in an document. Then I want to load it back into an UIWebView.

So I transform the document into an NSString

let myHTMLString = NSString(contentsOfFile: readPath, encoding: NSUTF8StringEncoding, error: &error) 

And I load it into my UIWebView doing

webView.loadHTMLString(myHTMLString, baseURL: nil)

Which actually works.

The aim is to save a website, and display it afterwards, in an offline mode. If the phone is in airplane mode, the UIWebView fails to download css, images and displays the static page (which is what I want)

But if the phone is connected to Internet, the UIWebView will use the network to load those dynamic contents (css, images ...)

Is there a way to prevent the UIWebView to use the network so that it will act as the phone would be in airplane/offline mode ?

(I could parse the html and remove some tags, but it would not be that easy)

0

There are 0 best solutions below