iPad startup rotation when orientation is flat up

Hello,

I need to detect what orientation is the UI of the iPad on launch. I used scripts found on this forum, based on the device orientation, and it works fine, except when the ipad is laying flat on the desk.

iOS obviously chooses an orientation for the splash screen and the videos but I have no idea how to get this.

I tried :

  • [[UIDevice currentDevice] orientation] : it returns the same data as Unity (orientation is FaceUp, so not usable)
  • [UIApplication sharedApplication].statusBarOrientation : always returns Portrait even when it’s not true
  • I tried to get the rootViewController of the key window of the application, but it is nil (!)

I think the right way is to get interfaceOrientation from a view controller, as it tells how the UI is rotated (as opposed to the others, that tell how the device is oriented).

But I cannont find any view controller in the xcode project, nor add one without breaking everything. I’ve been trying to resolve this for a week now and I still can’t find a solution…

Please help !

Camille

The status bar orientation is right, thats what unity sets it to be and as it never offers a rotation beyond it, it will never change basically.

Unity has no root view controller actually it has an eagl view pushed into a window, thats it basically.

What you can do best is what some users did: add a new view which responds to the rotation change request callback and push the eaglview as child of it upon its creation and make this new view its “root view” (not controller) within the window.

Thanks dreamora !

I added a new view which responds to the rotation change request callback, this works OK (I have the actual rotation of the UI).

But there is one last glitch (it can’t be easy, can it :P) … I get the orientation information… 1 frame late. Frustrating ! So between the splash screen and the actual unity rendering, sometimes for 1 frame the orientation is flipped. Can I “postpone” the first frame rendering ? What else can I do to avoid this glitch ?

Thanks again,
Camille

umm have a black screen and then fade in? stop panicking for gods sake :slight_smile: