5

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];
}
Jojo
  • 490
  • 1
  • 7
  • 22

2 Answers2

3

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

Mohammad Allam
  • 258
  • 2
  • 14
-1

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!

Joel
  • 2,285
  • 2
  • 21
  • 22