Open Cordavi opened 5 years ago
@andreamazz Do you have any insight into what may be causing this? I was trying to pinpoint it to put up a PR for it but having a hard time tracking it down.
Some additional investigation has shown that if I set shouldUpdateContentInset = false
the placement issue gets resolved. Having said that, even though the placement is fixed with it off, the buttons on the navigation bar become unresponsive and can not be tapped. If you hiding and show the bar again, they become tappable again.
Further investigation shows me that when scrolling down on an iPhone X the contentInset
top is being set to -44
which is the height of the navigation bar. This is normally reset to 0
when a user scrolls up after scrolling down.
When you scroll down and leave the application (in my case open a safari view controller), the content inset will get stuck at -44
even when scrolling up. If you repeatedly leave and come back, the inset will continue to grow more negative -44
+ the previous times.
This is also an issue if the user starts the swipe to go back gesture but does not complete it. It will cause the contentInset
to get stuck at -44
.
Having said that, even though the placement is fixed with it off, the buttons on the navigation bar become unresponsive and can not be tapped. If you hiding and show the bar again, they become tappable again.
It seems that the navigationBar.isUserInteractionEnabled
get stuck as false
when having shouldUpdateContentInset = false
set tapping a link to go to safari, coming back and tapping to scroll to the top. The code that would enable it when showing the navigation bar never gets called in this situation.
Hey @Cordavi Thanks for all the detective work, If that is the case it should be fairly easy to pinpoint the cause. Can you concoct a quick sample project showing the issue to help me debug this?
Here you go @andreamazz. To reproduce, I scroll to the bottom and click the link in the bio and then close the controller and scroll to the top. If you do that repeatedly, the amount will grow. example-AMScrollingNavBarBug.zip
I'm testing your sample, setting shouldUpdateContentInset
to false
seems to fix the issue (with hindsight I should have this default to false anyway).
I tried adding a bar button to the navigation bar and it seems to be working fine though, the user interaction is always restored. I'm testing with iOS12 though, I can't test against 13 now, maybe that's the issue?
@andreamazz Here is an updated project that should reproduce the interaction issue hopefully. It does for me on an iOS 12 device iPhone 7 Plus. Hope that helps 😃 example-AMScrollingNavBarBug.zip
I am going into the article. Scrolling to the bottom and tapping the link in the bio. Coming back to the page and then tapping the status bar to scroll to the top of the page and then trying to take the back button.
Describe the bug When presenting a
SFSafariViewController
on top of a view controller that uses aScrollingNavigationController
and returning to the app, the web view content will be behind the navigation bar when scrolling to the top. Upon inspecting various older version, this behavior was not apparent in version4.1.0
and before.To Reproduce Steps to reproduce the behavior:
Expected behavior The web view's content is not behind the navigation bar.
Screenshots