Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Modal dismissals do not account for status bar (new iOS 6 issue?)

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

like image 679
Charles Marsh Avatar asked Dec 09 '22 20:12

Charles Marsh


2 Answers

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

like image 140
Charles Marsh Avatar answered Jan 17 '23 03:01

Charles Marsh


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.

like image 21
Brian Robbins Avatar answered Jan 17 '23 04:01

Brian Robbins