Jojo
Jojo

Reputation: 490

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];
}

Upvotes: 5

Views: 1705

Answers (2)

Mohammad Allam
Mohammad Allam

Reputation: 258

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 :)

Upvotes: 3

Joel
Joel

Reputation: 2295

The problem seems to be

infoViewController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;

If you change this to

infoViewController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;

then it will no longer jump. This worked for me. Good luck!

Upvotes: -1

Related Questions