WKWebView not scrolling while UIWebView works fine

I am trying to embed a Tabelau dashboard into my iOS 13 app. When using WKWebKit, I am unable to scroll on the page, while UIWebView allows me to scroll. Here is the link to the tabelau dasboard. The page has both desktop and mobile versions. It also works fine in Safari on iOS. The only place where scrolling does not work is WKWebView.


What I tried:

1. This (injecting CSS)

2. isScrollEnabled = true

3. Several other things from Stack Overflow that involved injecting CSS.


Please feel free to ask any additional questions that could help you understand this problem better.


Thank you!

I had the same issue in my enterprise WKWebView app for iPad. Pulled my hair out trying to figure this one out for over a year, and for a while just used a legacy version of XCode to compile updates as a workaround.

The issue seems to be with the 'Desktop Class Browsing' feature released in iOS/iPadOS 13, when WKWebView started requesting desktop versions of sites automatically.

I was able to fix the issue by specifying a mobile UserAgent string using the the webView.customUserAgent property.

Example:
iPad UserAgent, gets desktop version of site, touches not handled properly:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10156) AppleWebKit/605.1.15 (KHTML, like Gecko)

iPhone UserAgent, gets mobile site, touches/scrolling work as expected:
Mozilla/5.0 (iPhone; CPU iPhone OS 141 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148_


I hope this helps!


WKWebView respects overflow:hidden on the <html> or the <body>. Check with Web Inspector to see if these are set on your page.

I had this problem, I was unable to scroll in this attached view and the issue has been fixed by adding these lines of code.

 override func panScrollable() -> UIScrollView? {     return webView.scrollView   }

 func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {     panModalSetNeedsLayoutUpdate()   }

WKWebView not scrolling while UIWebView works fine
 
 
Q