Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I detect orientation on app launch for splash screen animation on iPad!

Hi I have an app and I have two *.pngs for default splash screen:

Default-Landscape.png Default-Portrait.png

What I want is to animate this default splash screen away when my app is loaded and ready to go.

To achieve this I would normally present an UIImageView with either default-landscape or default-portrait (depending on the device orientation), keep it on screen for a certain time and then animate it away.

My problem is that if I call [[UIDevice currentDevice] orientation] in

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    

The answer is always that the device is in portrait orientation even if I clearly have it in landscape. I tried this in simulator and on the device as well and the behaviour is the same.

Does anyone know a fix for this or maybe some other approach?

Thanks!

like image 288
Horatiu Paraschiv Avatar asked Aug 13 '10 14:08

Horatiu Paraschiv


People also ask

What is a launch screen on an app?

A launch screen is simply a visual placeholder displayed to the user whilst the app is loading.

What is a launch image?

The launch image is visible on mobile devices when launching the app for the first time or when restarting the app. The launch image fills the whole screen for a few seconds until the app data loads and the app content is available. This bridges any gap in loading time and provides the user a seamless experience.


1 Answers

I had troubles with this and I solved it by making one image 1024x1024 and setting the contentMode of the UIImageView to UIViewContentModeTop, then using left and right margin autoresizing. So long as your portrait and landscape default images are the same layout then this will work fine.

Just to clarify here's what I used:

bgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:SplashImage]];
bgView.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
bgView.contentMode = UIViewContentModeTop;
like image 84
Rich Lowenberg Avatar answered Sep 16 '22 17:09

Rich Lowenberg