Reputation: 2934
Trying to disable bounce scrolling for WKWebview in macOS, but WKWebview in macOS has no "scrollView"
let webView = WKWebView(frame: view.frame)
print(webView.scrollView)
Upvotes: 8
Views: 4513
Reputation: 816
Scrolling can be disabled by overriding the WKWebView class:
class NoScrollWebView: WKWebView {
override func scrollWheel(with theEvent: NSEvent) {
nextResponder?.scrollWheel(with: theEvent)
return
}
}
See here: https://stackoverflow.com/a/62746859/9519322
Upvotes: 2
Reputation: 3789
One really weird thing about this that you may or may not have noticed is that in the WKWebView class, there is a description of the scrollView that is theoretically "supposed" to be in the class, but the scrollView is not there. This can be seen in the photo below:
I would say that it could be a weird procedure of Apple's, but see in the iOS class, the same description is present but with an actual scrollView this time:
Unless I am missing something major here, this would likely mean one of two things:
Either way this is a very weird finding.
You might want to consider doing some further research on this, and perhaps filing a Swift bug report.
EDIT:
It was pointed out to me that this scroll view is in-fact a iOS only property, and the unnecessary comment is the bug.
Upvotes: 2