Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Web view's content behind navigation bar when returning from safari view controller #366

Open
Cordavi opened this issue Jul 24, 2019 · 8 comments

Comments

@Cordavi
Copy link

Cordavi commented Jul 24, 2019

Describe the bug
When presenting a SFSafariViewController on top of a view controller that uses a ScrollingNavigationController 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 version 4.1.0 and before.

To Reproduce
Steps to reproduce the behavior:

  1. Setup a view controller with a scrolling navigation bar and a web view
  2. Tap a link in the web content and open a safari view controller
  3. Return to the app and scroll to the top, the content will be behind the navigation bar.

Expected behavior
The web view's content is not behind the navigation bar.

Screenshots

Jul-24-2019 17-26-25
Simulator Screen Shot - iPhone X - 2019-07-24 at 17 26 47

@Cordavi
Copy link
Author

Cordavi commented Jul 29, 2019

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

@Cordavi
Copy link
Author

Cordavi commented Jul 29, 2019

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.

@Cordavi
Copy link
Author

Cordavi commented Jul 29, 2019

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.

@Cordavi
Copy link
Author

Cordavi commented Jul 29, 2019

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.

@andreamazz
Copy link
Owner

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?

@Cordavi
Copy link
Author

Cordavi commented Jul 30, 2019

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

@andreamazz
Copy link
Owner

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?

@Cordavi
Copy link
Author

Cordavi commented Aug 1, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants