Search code examples
ioscssswiftwebviewwkwebview

CSS not loading in WKWebView


I am trying to create a simple WebView app using UITabBarViewController. The CSS does not load when I use Tab Bar. If I use a simple View Controller, the CSS loads. There are no other changes to the code.enter image description hereenter image description here

let request: NSMutableURLRequest = NSMutableURLRequest(url: myUrl)

    if (webView != nil) {

    } else {
        self.loadView()
        self.webView.navigationDelegate = self
    }
    if (self.finishedUrl != myUrl.absoluteString) {
        webView.load(request as URLRequest)
    }

Solution

  • So, I was able to solve the problem and the problem was /. If you put / to the end of url, CSS doesn't load. But, if you don't put / to the end, CSS gets loaded.