AMScrollingNavbar icon indicating copy to clipboard operation
AMScrollingNavbar copied to clipboard

ScrollView sometimes doesn't get back to it's default position.

Open heruvilius opened this issue 7 years ago • 10 comments

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.

heruvilius avatar Apr 09 '18 15:04 heruvilius

+1

sbelmeha avatar Apr 10 '18 12:04 sbelmeha

+1

xgoo avatar Apr 11 '18 06:04 xgoo

@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

andreamazz avatar Apr 11 '18 09:04 andreamazz

@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 avatar Apr 11 '18 09:04 andreamazz

@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?

heruvilius avatar Apr 11 '18 10:04 heruvilius

I should follow the webView itself instead?

Exactly

andreamazz avatar Apr 11 '18 10:04 andreamazz

@andreamazz the problem still persists. Maybe the issue is my view hierarchy? I shall describe it again.

MyViewController:
    - UINavigationBar
    - UIView:
        -- WKWebView
        -- UIView
        -- UIView
    - UIToolbar

heruvilius avatar Apr 11 '18 10:04 heruvilius

Looks like contentInset and scrollIndicatorInsets should be reseted as it's done with contentOffset. At least it resolved my case.

sbelmeha avatar Apr 11 '18 12:04 sbelmeha

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 avatar Apr 11 '18 12:04 andreamazz

@andreamazz same with #238 ?

neaped avatar Jul 02 '18 13:07 neaped