Search code examples
iosipadwkwebview

Wikipedia renders WkWebView and Safari differently on an iPad


This problem is iPad specific.

When I use a WKWebView inside my app, its User Agent field is identical to the one sent by Safari. However, the page returned by Wikipedia to my App includes the standard Wikipedia side-bar. Safari on the iPad does not show the side bar.

I would like WKWebview to behave the same was as Safari. I would appreciate suggestions.


Solution

  • You can use SFSafariViewController instead Its behaviour is identical to Safari

    if let url = URL(string: urlString) {
            let config = SFSafariViewController.Configuration()
            config.entersReaderIfAvailable = true
    
            let vc = SFSafariViewController(url: url, configuration: config)
            present(vc, animated: true)
        }