I have a tableViewController with a dynamic UIView inside it, where it's layer position changes so that it stays underneath the status bar. I did the same to a regular View controller with a UIScrollView.
Where the "status banner" in the tableViewController does what it is suppose to, the status banner in the viewController does not.
The status bar's position is modified in a viewDidScroll method within each view controllers.
Why isn't the banner in the second view controller not moving?
Here is the code, it is the same in both view controllers:
-(void)scrollViewDidScroll: (UIScrollView*)scrollView
{
CALayer *layer = _statusBanner.layer;
float scrollOffset = scrollView.contentOffset.y;
if (scrollOffset > 10)
{
[[self navigationController] setNavigationBarHidden:YES animated:YES ];
[_statusBanner setHidden:NO];
layer.position = CGPointMake(layer.position.x, scrollOffset + 10);
}
else {
[[self navigationController] setNavigationBarHidden:NO animated:YES ];
[_statusBanner setHidden:YES];
}
}
I figured a workaround with this issue. I had decided to leave statusBanner out of the scrollView of the viewController. The banner and the scrollview are both wrapped in the primary UIView of the viewController and the banner is placed just above scrollView.
I was looking too hard at the problem to see the easiest solution.