ScrollView sometimes doesn't get back to it's default position.
Hello.
Am am using this framework with WKWebView to minimize Navigation Bar when scrolling downwards. I am facing a problem when Navigation Bar has its full height, but my web view is offset as if the bar has its small height.
Here is the video, where everything works fine. And here is the video, where the behaviour is undesired.
To use the framework I've added the following lines into View Controller that manages WKWebView:
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
// My other code
// ...
guard let navigator = navigationController as? ScrollingNavigationController else { return }
navigator.followScrollView(webView.scrollView, delay: 55.0)
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
guard let navigator = navigationController as? ScrollingNavigationController else { return }
navigator.stopFollowingScrollView()
}
webView is a UIView that has WKWebView instance inside its view hierarchy, as well as some other views. It's scrollView property simply returns WKWebView instance's scrollView property.
+1
+1
@landsv @xgoo either provide constructive feedback or avoid meaningless +1, GH reactions were implemented for a reason. Bugging me with a notification is not going to help me fix the issue. Thanks
@heruvilius I'm not sure I fully understand what you mean. Sometimes it works and sometimes it doesn't? I'd advise against following the webview's scrollview, since the library already does that internally.
@andreamazz "Sometimes it works and sometimes it doesn't?" - yes, that's exactly what is happening.
"I'd advise against following the webview's scrollview, since the library already does that internally." - so I should follow the webView itself instead?
I should follow the webView itself instead?
Exactly
@andreamazz the problem still persists. Maybe the issue is my view hierarchy? I shall describe it again.
MyViewController:
- UINavigationBar
- UIView:
-- WKWebView
-- UIView
-- UIView
- UIToolbar
Looks like contentInset and scrollIndicatorInsets should be reseted as it's done with contentOffset. At least it resolved my case.
Looks like contentInset and scrollIndicatorInsets should be reseted as it's done with contentOffset. At least it resolved my case.
Where did you reset the insets?
The contentOffset is reset in case of a translucent navbar, it doesn't seem @heruvilius' case, judging by the videos above.
@andreamazz same with #238 ?