I have a web page for testing purposes (https://storage.googleapis.com/htmltestingbucket/nested_scroll_helper.html) that just prints a counter of the scroll event the html has caught in a fixed header
When the WKWebView is the only scroll-able element in the fragment everything is fine and the WebView sends the scroll events to the page
If I want to add native elements above and below the WebView then things get much more complex.
UIScrollView
UILabel
WKWebView
UILabel
I know it's not good to have a WebView inside a ScrollView but I have to provide a single scrolling experience with hybrid content and proper scrolling events in the html document. I found plenty of questions on the matter but I was not able to create a full end-to-end solution.
Update: Okay took me a while to understand what you're trying to do.
I know you would like to keep the outer scrollView, but I'm pretty sure it's not possible to achieve what you want to do (only way could be if you set the outerScrollView.delegate = webView
- but didn't work for me when I tried)
I think the best solution would be:
webView.contentInset = UIEdgeInsetsMake(100,0,100,0);
Previously (Other way around):
webView.scrollView.scrollEnabled = NO;
in your viewDidLoad
or the storyboardwebView.scrollView.contentSize.height
s content height via
self.webViewContentHeightConstraint.constant = webView.scrollView.contentSize.height
Don`t forget to do steps 4 & 5 whenever the webView did finish loading content
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With