Note that there are some explanatory texts on larger screens.

plurals
  1. POStatusBar and RootViewController on iOS 6
    primarykey
    data
    text
    <p>My app has been running fine for a couple years, but there have been several hiccups with the release of iOS 6 and one of them is a problem with StatusBar orientation.</p> <p>My app works in either Landscape orientation, but touches were vertically off by the width of the status bar in one of the two orientations. Intuitively, it seemed that even though the status bar image was being relocated properly during rotation, the LOGICAL position of the status bar was not changing -- and thus consuming touches on the wrong side of the screen.</p> <p>In my Info.plist file "UIStatusBarHidden" was set to FALSE. In my App Delegate's "didFinishLaunchingWithOptions" function I created my own custom ViewController and set it as the RootViewController for the Window. Even though this worked prior to iOS 6, I believe it is at this point that the StatusBar did not "transfer" to the new RootViewController.</p> <p>I theorized that prior to iOS 6 my code worked because orientation changes got propagated to the OLD RootViewController and caused orientation to work as expected. Since iOS 6 no longer propagates orientation beyond the NEW RootViewController, the OLD controller (which "logically" contained the StatusBar) never got updated.</p> <p>Note: my app does not have a .XIB file and does not explicitly create a RootViewController until this point. But I think a default one was created for me behind the scenes anyhow.</p> <p>My "solution" was to set "UIStatusBarHidden" to TRUE in the Info.plist file and manually set it to FALSE in code at a point AFTER I've set my custom RootViewController. This seems to work, but I may have addressed the symptom instead of the actual problem.</p> <p>I'm also worried about side-effects because other things besides StatusBar could still be logically tied to that old/implicit RootViewController and they aren't getting "transferred" to the new one either.</p> <p>Does anyone have similar experience with StatusBar and/or RootViewController? Is this approach ok or should I leave the default/implicit RootViewController in place and somehow add my ViewController to it as a child? That didn't seem to work when I first wrote the code two years ago, which lead to my current implementation.</p> <p>Below are the highlights of the code in questions. Thanks in advance for the advice.</p> <p>-BT</p> <pre><code>// ******** Info.plist value ********* &lt;key&gt;UIStatusBarHidden&lt;/key&gt; &lt;true/&gt; // ******** App Delegate ********** - (BOOL)application : (UIApplication *)application didFinishLaunchingWithOptions : (NSDictionary *)launchOptions { CGRect rect = [[UIScreen mainScreen] applicationFrame]; rect.origin.x = 0; rect.origin.y = 0; self.window = [[[UIWindow alloc] initWithFrame:rect] autorelease]; self.gameViewController = [[[GameViewController alloc]init] autorelease]; self.gameView = [[[GameView alloc] initWithFrame:rect] autorelease]; [self.gameViewController.view addSubview : self.gameView]; [self.window setRootViewController:self.gameViewController]; // Setting it now attaches it to our actual RootViewController instead of the // "phantom" controller created under the hood? [UIApplication sharedApplication].statusBarHidden = NO; // ... } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload