andreamazz / AMScrollingNavbar

Scrollable UINavigationBar that follows the scrolling of a UIScrollView
MIT License
6.05k stars 633 forks source link

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

Open heruvilius opened 6 years ago

heruvilius commented 6 years ago

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.

sbelmeha commented 6 years ago

+1

xgoo commented 6 years ago

+1

andreamazz commented 6 years ago

@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 commented 6 years ago

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

heruvilius commented 6 years ago

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

andreamazz commented 6 years ago

I should follow the webView itself instead?

Exactly

heruvilius commented 6 years ago

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

MyViewController:
    - UINavigationBar
    - UIView:
        -- WKWebView
        -- UIView
        -- UIView
    - UIToolbar
sbelmeha commented 6 years ago

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

andreamazz commented 6 years ago

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.

neaped commented 6 years ago

@andreamazz same with #238 ?