Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does my Navigation Bar temporarily disappear when I dismiss a modal view in iOS 7?

When I'm going back from my Modal View Controller to my Main View Controller (I have a horizontal animation) my Main Controllers navbar places itself a bit too high for a quick second and then jumps back to its right position. Does somebody know why? Ive been googling it but with no success.

App Delegate:

 [navigationController.navigationBar setBarTintColor: [UIColor whiteColor]];
 [navigationController.navigationBar setTranslucent: NO];

When i push button to open my Info View:

UIViewController *infoViewController;
infoViewController = [[InfoViewController alloc] initWithNibName:@"InfoViewController" bundle: nil];
infoViewController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentViewController: infoViewController animated: YES completion:nil];

I'm not using Auto Layout on any xib-files. My Main View Controller xib-file is empty with Status Bar: Default. My Info View Controller xib-file has some stuff in it.

Code for closing my Modal View Controller:

-(IBAction)onBackBtnClick:(id)sender
{
    [self dismissModalViewControllerAnimated: YES];
}
like image 517
Jojo Avatar asked Nov 02 '22 14:11

Jojo


1 Answers

All what you have to do is to add the following code in the ViewWillAppear of the "InfoViewController" viewController class

-(void) viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];

    [self.navigationController.navigationBar setTranslucent:NO];
    [self.navigationController.navigationBar.layer removeAllAnimations];
}

Hope it worked with you :)

like image 93
Mohammad Allam Avatar answered Dec 01 '22 17:12

Mohammad Allam