Reputation: 17920
In my root view, I create a navigation controller and add it 20 px below the status bar.
My Navigation View controller
The status bar appears normal.
When I click Back, (Freezed Animation for screenshot).
The view moves up when the animation is happening. And After it completes, the status bar appears back.
Code: This is how I add the navigation controller to my VC
In RootView:
navController = [[UINavigationController alloc]initWithRootViewController:myView];
navController.navigationBar.translucent = YES;
navController.view.autoresizingMask = UIViewAutoresizingNone;
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7) {
CGRect frame=navController.view.frame;
frame.origin.y += 20;
frame.size.height-=20;
navController.view.frame=frame;
}
Upvotes: 0
Views: 1742
Reputation: 17920
This answer helped me a lot.
Push / Pop View Controller With Navigation Bar from View Controller Without Navigation Bar
I add my navigation controller with first VC, and it wants the navigation bar hidden
I had it as animated:NO
in below snippet.. The correct usage has to be using the animation boolean
from the delegate itself.
In VC1: The Navigation Bar should be hidden
I have to hide the navigation bar like below.
-(void)viewWillAppear:(BOOL)animated {
// Hide the bar with animation how viewWillAppear is called
[self.navigationController setNavigationBarHidden:YES animated:animated];
}
When I push VC2 to VC1, I need to enable the navigation bar back. So in VC1 itself, during the disappear iI do the below.
-(void)viewWillDisappear:(BOOL)animated{
// Show the bar with animation how viewWillDisappear is called
[self.navigationController setNavigationBarHidden:NO animated:animated];
}
In VC2: The Navigation Bar should be shown
When I press back in VC2, I actually have to hide the navigation bar again. So, I do it in viewWillDisappear.
-(void)viewWillDisappear:(BOOL)animated{
// Hide the bar with animation how viewWillAppear is called
[self.navigationController setNavigationBarHidden:YES animated:animated];
}
The Main key is
animated:animated
and notanimated:NO
.. Unbelievable.!
Upvotes: 1
Reputation: 1345
So I believe this is your problem
frame.origin.y += 20;
frame.size.height-=20;
navController.view.frame=frame;
It has been called every time your view load. I believe if you go forward and backward many times the view is going up on your window. is it? If yes. Make sure that will be called just once.
I hope this helps you.
Upvotes: 1