如何检测iPad上启动画面动画的应用启动方向! [英] How do I detect orientation on app launch for splash screen animation on iPad!

查看:171
本文介绍了如何检测iPad上启动画面动画的应用启动方向!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨我有一个应用程序,我有两个* .pngs用于默认启动画面:

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

Default-Landscape.png
Default-Portrait.png

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.

为了达到这个目的,我通常会提供一个带有默认横向或默认肖像的UIImageView(取决于设备方向),将其保留在屏幕上一段时间,然后将它设置为动画。

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.

我的问题是如果我在 [[UIDevice currentDevice] orientation] 中调用

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?

谢谢!

推荐答案

我遇到了麻烦,我解决了这个问题图像1024x1024并将UIImageView的contentMode设置为UIViewContentModeTop,然后使用左右边距自动调整。只要你的肖像和风景默认图像是相同的布局,那么这将工作正常。

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;

这篇关于如何检测iPad上启动画面动画的应用启动方向!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆