I am trying to preload websites, but I'm having trouble loading the CSS with loadHTMLString. The webView loaded from loadHTMLString looks like the CSS is missing from some parts. How do I make it so that in my NSURLSession, the CSS and HTML and everything else that makes up the website is loaded correctly?
My function to extract all the data from the webpage.
var myData1: NSString!
func loadURL(){
let url = NSURL(string: "https://m.facebook.com")
let reqURL = NSURLRequest(URL: url!)
let session = NSURLSession.sharedSession().dataTaskWithRequest(reqURL){
(data, response, error) in
var myHTMLString = NSString(data: data, encoding: NSUTF8StringEncoding)
self.myData1 = myHTMLString
}
session.resume()
println("1 loaded")
}
The button that will actually load the page in
@IBAction func loadWeb1(sender: AnyObject) {
self.googlePlusWeb.loadHTMLString(myData1 as! String, baseURL: NSURL(string: "https://m.facebook.com"))
}