2

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.

prior to hiding

I hide the navigation bar because it looks like I can't put any views on top of it without unhiding it.

after hiding and putting view in front

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.

subviews still seems to be shifted upwards even after running code to shift them down

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.

Luke
  • 1,053
  • 2
  • 16
  • 26
  • See this link http://stackoverflow.com/a/19025547/1545180 you can get ride out of the status bar issue. – Ganapathy Nov 12 '13 at 04:46
  • @Ganapathy thanks, but I suspected that doesn't solve the navigation bar issue, but rather status bar. I tried it but unfortunately it didn't seem to work. – Luke Nov 12 '13 at 05:45
  • have you un-commented all the line you have returned regarding the status bar issue while trying to fix with delta value us i mentioned. If not it will give the side effects thats y. – Ganapathy Nov 12 '13 at 05:47

0 Answers0