4

Didn't have this issue at all until I began adapting my app for iOS 6. Whenever I return from a modal segue (with dismissViewControllerAnimated:completion:), my main view is shifted up by about the status bar's height worth of offset (and is subsequently behind the status bar).

The only workaround I've found is to add:

self.navigationController.view.frame = CGRectMake(0, 20, 320, 460);
self.view.frame = CGRectMake(0, 0, 320, 416);

to my dismissViewControllerAnimated:completion method (those values are for an iPhone < 5 and are just for explanation). But this doesn't really solve the problem, because when I go to present the next modal view controller, the presented view is then shifted up by about the status bar's height worth of offset.

No idea how this issue arose. My suspicion is that, somewhere in the segue, one of the navigation controllers loses track of the status bar's existence (linked to the new status bar, in some way?).

EDIT: a screenshot of the main view, post-modal dismissal. [Note: 20px whitespace on the bottom] enter image description here

Charles Marsh
  • 1,877
  • 16
  • 21

3 Answers3

13

Resolved the issue. My custom navigationController's supportedInterfaceOrientations was returning UIInterfaceOrientationPortrait, rather than UIInterfaceOrientationMaskPortrait.

bluish
  • 26,356
  • 27
  • 122
  • 180
Charles Marsh
  • 1,877
  • 16
  • 21
1

Your answer didn't work for me either but I found this solution by Mike Foster that did: http://fostah.com/ios/2012/09/27/ios6-orientation-handling.html

His steps are:

  1. add the applications supportedInterfaceOrientation and have it return UIInterfaceOrientationMaskAll (or in my case I used AllButUpsideDown)
  2. In your rootViewController implement shouldAutorotate and have it return NO
  3. DO NOT implement supportedInterfaceOrientations in your rootViewController (this seems to be the step that was causing problems with the status bar for me)
  4. In the viewController that should be landscape implement shouldAutorotate to return NO and supportedInterfaceOrientations to return UIInterfaceOrientationMaskLandscape

Hopefully that helps a few other people.

Brian Robbins
  • 1,619
  • 1
  • 12
  • 7
0

This answer didn't work for me, even though I have the same structure with a custom navigationController as the rootViewController. In my app, I want it in portrait for all VCs except for my modals, which will be UIInterfaceOrientationMaskAll.

What did work was a variation on your workaround, except it will account for iPhone 4 and iPhone 5 screen sizes and the height of the navBar:

[yourParentVC dismissViewControllerAnimated:NO completion:^{

    [yourParentVC.view setFrame:CGRectMake(0, 0, [UIScreen mainScreen].applicationFrame.size.width, [UIScreen mainScreen].applicationFrame.size.height-44)];
    //your other completion code
}];

+1 for asking this question...not happy how much work it's been accounting for all the deprecations in iOS 6, so every little bit helps.

whyoz
  • 5,168
  • 47
  • 53