3
votes

I am trying to view the website https://www.methodenguide.de/basic inside a WKWebView. The website itself loads, but it doesn't behave as it should or as it does in Safari:

  • The boxes on the homepage don't show images
  • Links don't load targetet urls (didFinish navigation method says page is loaded instantly, but in fact nothing seems to happen)
  • Navigation menu is not shown properly (compared to Safari view).

The website works perfectly in Safari on the iPhone, so there seems to be a problem with the WKWebView, but I have no clue where to look ...

Any help is appreciated, as I'm fairly new to iOS / Swift development! Thanks in advance, everybody :)


    @IBOutlet weak var website: WKWebView!

    override func viewDidLoad() {
        super.viewDidLoad()

        website.navigationDelegate = self

        let request = URLRequest(url: URL(string: "https://www.methodenguide.de/basic")!)

        website.load(request)

        website.addObserver(self, forKeyPath: #keyPath(WKWebView.estimatedProgress), options: .new, context: nil)
        website.addObserver(self, forKeyPath: #keyPath(WKWebView.title), options: .new, context: nil)

    }

func webView(_ website: WKWebView, didStartProvisionalNavigation navigation: WKNavigation!)
    {
        print("Began loading page")
    }

    func webView(_ website: WKWebView,
                 didFinish navigation: WKNavigation!)
    {
        print("Finished loading page")
    }
1

1 Answers

0
votes

The answer lies in the info.plist. You need to enable http (not secure) connections as the images are loaded via ajax or the certificate is not secure.

App Transport Security Settings:

Allow Arbitrary Loads in Web Content
Allow Arbitrary Loads

Set both to YES.

enter image description here