Note that there are some explanatory texts on larger screens.

plurals
  1. POMy app starts upside down
    text
    copied!<p>An engine that I've worked on for a while and has shipped games is now launching my current project upside down and right away rotates the UIView the way it suppose to be. I create the interface with code and this is about how it looks like:</p> <pre><code>- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { ... CGRect screenBounds = [[UIScreen mainScreen] applicationFrame]; CGRect windowBounds = screenBounds; windowBounds.origin.y = 0.0; UIWindow* win = [[UIWindow alloc] initWithFrame:windowBounds]; win.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; UIMyView* view = [[UIMyView alloc] initWithFrame:screenBounds]; UIMyViewController* controller = [[UIMyViewController alloc] init]; controller.view = view; view.multipleTouchEnabled = true; view.windowWrapper = this; view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; [win addSubview:view]; ... } - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation; { s32 validOrientations = ((cViewMM*)(self.view)).windowWrapper-&gt;GetValidOrientations(); if (toInterfaceOrientation == UIInterfaceOrientationPortrait &amp;&amp; (validOrientations &amp; 0x01)) return true; if (toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown &amp;&amp; (validOrientations &amp; 0x02)) return true; if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft &amp;&amp; (validOrientations &amp; 0x04)) return true; if (toInterfaceOrientation == UIInterfaceOrientationLandscapeRight &amp;&amp; (validOrientations &amp; 0x08)) return true; return false; } </code></pre> <p>The problem occures only if I want to launch the application in UIInterfaceOrientationLandscapeLeft. Debugging through the application it looks like when I try to add my view to the window internally the shouldAutorotateToInterfaceOrientation: is called multiple times. First with UIInterfaceOrientationPortrait which returns false then UIInterfaceOrientationLandscapeRight which return true (since it's valid orientation) and then UIInterfaceOrientationLandscapeLeft which also returns true (since it's valid orientation and it's the current orientation of the device).</p> <p>Oh and to be more specific this is happening only on iPhone not on iPad. They use the same code to setup this view.</p> <p>What am I doing wrong?</p> <p>-- EDIT --</p> <p>OK I was wrong about the execution of shouldAutorotateToInterfaceOrientation: it is executed 3 times asking for UIInterfaceOrientationPortrait, 2 times for UIInterfaceOrientationLandscapeLeft, then once for UIInterfaceOrientationLandscapeRight, and again once UIInterfaceOrientationLandscapeLeft. </p> <p>GameCenter is alreay initializing at this point and since it's pushing some extra UI I thought it may be it, but it wasn't.</p>
 

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