Andy A
Andy A

Reputation: 236

Anyone know how to remove unwanted animation from navigation bar? Screenshots

I have a view controller which proceeds via a button to a table view controller.

In the view controller, the navigation bar is totally translucent (As you can see in the screen shot below). On the table view controller, the navigation bar is set to white.

My problem is, when I press 'back' in the table view and return to the view controller, the white navigation bar is carried over for a moment (see top image) before disappearing in an ugly animation.

Extra Navigation bar space: Unwanted navigation bar carry over

How I want it to always look: How it should look

I have tried pretty much everything I can think of, all my code relating to the navigation bars translucency is in viewDidAppear, so why is this happening!?

Someone please tell me what I'm doing wrong! This is making me crazy!

Upvotes: 0

Views: 373

Answers (2)

Gyanendra
Gyanendra

Reputation: 361

You can do some thing like this have a custom back button below is the code

UIButton *backButton = [UIButton buttonWithType:UIButtonTypeCustom];
backButton.frame = CGRectMake(2, 1, 29, 29);
[backButton setBackgroundImage:[UIImage imageNamed:@"back_button"] forState:UIControlStateNormal];
[backButton addTarget:self action:@selector(backButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
backButton.adjustsImageWhenHighlighted = NO
item.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:backButton];

where item is instance of UINavigationItem and in selector of back button

-(void)backButtonClicked:(id)sender {

[self.navigationBar popNavigationItemAnimated:NO];

}

by doing this the navigation bar will pop the item but without animation.

Upvotes: 0

Nikos M.
Nikos M.

Reputation: 13783

In the tableviewcontroller set:

- (void)viewWillDisappear:(BOOL)animated {
 // put the code for the uinavigation bar styling here.
}

Upvotes: 1

Related Questions