Iphone – the old display shifts-down-after-modal-view-controller issue

cocoa-touchiphoneiphone-sdk-3.0uikit

I've checked the other answers but have not found anything that really describes my situation. So here goes.

I have a window-based app that creates and loads a UIViewController from xib. It has status bar disabled, height of 480 and a UISegmentedControl with y origin of 451. It displays nicely at the bottom of the screen.*

In viewDidLoad of the UIViewController I create a UIView initWithFrame:CGRectMake(0.0, 0.0, 320.0, 431.0)]; (that's 480 – 29 pixels for the UISegmentedControl and 20 for the status bar.) I add it to the UIViewController with [self.view addSubview:gameBoard];. Then some UIView game pieces are added as subviews of the gameboard UIView and everything is displayed as I think it should be.

When some of those UIView subviews are tapped, a menu should appear. I have created a UIViewController with the required controls on it. I use a delegate method to call from the subviews, who pick up the triggering events, to the root UIViewController – which does

self.squadOrders = [[SquadOrders alloc] initWithNibName:@"SquadOrders" bundle:nil];
    squadOrders.viewControllerDelegate = self;
    [self presentModalViewController:squadOrders animated:YES];

And the modal dialog displays as I think it should, sliding up from the lower edge of the screen, not covering the status bar but covering the UISegmentedControl mentioned at the bottom of the root UIViewController. It gets dismissed by

[self dismissModalViewControllerAnimated:YES];

and that's where the trouble begins. The UISegmented control is moved down by 20 pixels so that only 9 pixels of it is visible at the bottom of the screen. There is a 20 pixel white gap at the top where the view has been moved down.

*enabling the status bar on this or any other xib does not change the described behavior at all.

Other stackoverflow questions related are:

IPhone – After dismissing Modal View Controller – gap is left at top of page – but the given solution was don't have another view controller loaded as a subview of the view controller that displays the modal – but I don't, only UIViews. There's also the suggestion of just resetting the appropriate frame after the modal goes away but it feels like cheating.

Contents of UIScrollView shifted after dismissing ModalViewController – I've played with the heights of all the views and controllers – am sure they match, hasn't helped. Again, the frame can be reset but it only addresses the symptom.

There are others but nothing is solving this issue so far.

Best Answer

I've just solved this issue with view shifting down. It was because of navigationBar.barStyle set to UIBarStyleBlackTranslucent.