I have a view controller that upon pressing a button, hides the navigation bar by using
[self.navigationController setNavigationBarHidden:true animated:YES];
and show another view in its place that I unhide.
I hide the navigation bar because it looks like I can't put any views on top of it without unhiding it.
Anyways, I noticed all the subviews got shifted upwards after hiding the navigation bar, so I did the following for all my subviews
// shift subviews down b/c of offset
CGRect categorizationSearchBarFrame = _categorizationSearchBar.frame;
categorizationSearchBarFrame.origin.y += IOS_7_OFFSET;
_categorizationSearchBar.frame = categorizationSearchBarFrame;
CGRect collectionViewFrame = _collectionView.frame;
collectionViewFrame.origin.y += IOS_7_OFFSET;
_collectionView.frame = collectionViewFrame;
I remembered to unhide the navigation bar and storing the "navigation hidden state" when navigating to other view controllers, so I can recreate the state coming back.
However, when I do come back and detects the "hidden state" in
viewWillAppear
and proceed to do that same unhide, offset procedure, the subviews still appear to be shifted upwards.
Only when I put the restoration code in
viewDidAppear
does the state get restored correctly. But since the view already appeared on screen, there's an annoying glitch that happens as a result. Does the view have to be shown before doing any offset changes? Would love someone's input on this. Thank you.