问题
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)
回答1:
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:
- There should be a scrollView but there isn't (i.e. it was accidentally deleted by Apple???)
- The scrollView was removed from the macOS WKWebView, but the description was accidentally left in the class?
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.
来源:https://stackoverflow.com/questions/39929552/disable-bounce-scrolling-for-wkwebview-in-macos