I have a UINavigationController
and its navigationBar
hides if the user scrolls (done with UIScrollViewDelegate
, not with pan gesture).
But when I push a a new viewController
onto the stack, the new controller's view's origin y is at 64px and not where the old topViewController
's y was (which is 21px).
How can I make the push, so that the new controller appears at the same position as the old one was?
The only place that updating the view's frame was successful was in viewDidAppear
, but that's to late, because the user can see a black space on the top for a second.
Updated:
It seams like it has to be done between viewWillAppear
and viewDidAppear
, but I can not find reasonable method to do this.
Tried to alter the UINavigationController
's view (currently I'm just moving it's navigationBar
), but that messes up the layout.
Update again:
Some more info, because none of the answers and comments helped. The navigationcontroller is instantiated from storyboard. It's a custom UINavigationController
, which hides the navigationBar
on it's topViewController
's scrollView
scrolling (nothing else is overwritten).
The first topViewController
(from which the push is started) is a UIViewController
with 2 container view (one if logged in, other if not). The second topViewController
(the one which is pushed onto the stack) is a UIViewController
with a full screen UIWebView
.
Everything is coming from the storyboard. All the Extended Edges
checkboxes are off for every viewController
and all the navigationBars
are opaque. AutoLayout
is used everywhere and (I think setup right).
navigationBar.translucent
andnavigationBar.opaque
These properties changes the originY of the ViewController's view. – Srikanthbool
property to access whether the navigationBar was hidden in the viewController when pushing a new VC. In the viewWillAppear, I check if the navBar was hidden. If yes, I set it's frame. I'm not sure whether it's best practice, but it does the job. – n00bProgrammerviewWillAppear
doesn't work. When it gets toviewDidAppear
the frame is back to the original. Something is altering the frame betweenviewWillAppear
andviewDidAppear
. – szotyi