This fixes a bug where the Nav Bar expands after being collapsed, but looks empty under some circumstances.
This happens when the the scroll view's UIViewController presents a new UINavigationController modally (.overFullScreen), and after the Nav Bar was previously collapsed by scrolling up. At this point, windowDidBecomeVisible() is called, which in turns calls showNavbar().
When showNavbar() executes at this point, the value of the state is .expanded so the method call simply exits without doing anything. The issue is that the alpha value was set to zero when the Nav Bar was previously collapsed, and it is still zero at this stage so the Nav Bar appears empty.
This fixes the immediate issue at hand, and I am pretty confident that the change doesn't cause any harm.
This said I suspect there may be a better way to address this? In particular when showNavbar() executes, the state should be .collapsed, not .expanded - I suspect this has to do with the way the modal UINavigationController interacts with the Nav Bar (?!? This is where I have more questions than answers)
More question than answers should have been the name of this repo, it's about constantly fighting against UIKit :)
This seems a safe workaround, thanks for your contribution.
This fixes a bug where the Nav Bar expands after being collapsed, but looks empty under some circumstances.
This happens when the the scroll view's
UIViewController
presents a newUINavigationController
modally (.overFullScreen
), and after the Nav Bar was previously collapsed by scrolling up. At this point,windowDidBecomeVisible()
is called, which in turns callsshowNavbar()
.When
showNavbar()
executes at this point, the value of the state is.expanded
so the method call simply exits without doing anything. The issue is that the alpha value was set to zero when the Nav Bar was previously collapsed, and it is still zero at this stage so the Nav Bar appears empty.This fixes the immediate issue at hand, and I am pretty confident that the change doesn't cause any harm. This said I suspect there may be a better way to address this? In particular when showNavbar() executes, the state should be
.collapsed
, not.expanded
- I suspect this has to do with the way the modal UINavigationController interacts with the Nav Bar (?!? This is where I have more questions than answers)