iPad UIInterfaceRotation is 0, rotation messed up on app-start
-
29-10-2019 - |
Question
i guess i missed something really important in the apple manuals which causes me having this problems.
I will describe what i want to have and what i get instaed + what i do.
Preamble:
- goal of my work is a app having a login-screen. this screen is supposed to be placed ontop of all other views, to fade out later. so in this case i guess i already break a rule, in case i understood that "only-one-main-window-guideline" correctly.
What i want:
- having an universal application √ check
- having an universal application which has UIInterfaceRotation for iPad only √ check
- not having troubles regarding uiinterfaceorientation or uideviceorientation on startup allowing me to show all views in proper dimension without having to rotate a few times to have it all properly positioned. - not checked
What i get:
- when i start the app in landscape, which is default orientation from my views in interface-Builder, its perfeclty aligned and i can rotate all i want, its perfect, stays perfefct, hooray
- when i start the app in portrait, i see the landscape-views flying around on the screen - each time on diffrent pace - at least that seems like. when i rotate the app now, forth and back, its all aligned as it should - also perfectly as wanted.
What i do:
- 99% of all rotation-related settings is made in interface builder, i currently just have some did-change-methods to change background-images when rotation is done and so on.
i noticed, that even when i build the screen after device knows its orientation, it leads to this.
so in other words:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[self addEventListener:UIDeviceOrientationDidChangeNotification sel:@selector(buildScreen)];
....
note: addEventListener is a small notification-category i created for easier handling. so no magic in here.
in build-screen i add all subviews. at first, the actualy screen in the background, this screen will get the login as subview (which does not matter since when i add login to main-window itself, situation is the same).
So in this case, i really dont know what do do next. Once orientation-alignment is setup, it all fits perfectly as i defined in IB.
Any help, links, code, etc, appreciated. thank you very much! i tried searching for this, just found many similar problems, no solutions. so a little sorry in case i seem to ask the very same question, a big one if i really do.
Best Regards
Solution 2
I did not find a proper solution, so i used multiple-xib
files to get it done. It's annoying but it works well.
OTHER TIPS
I wouldn't normally recommend this because i think it's annoying as a user, but you could try the Info.plist setting
Initial interface orientation
and set this to the Landscape if this is what works for you.
Could be a temporary workaround. I recon your issues are much more complex though than a simple suggestive fix.