如何检测iPad上启动画面动画的应用启动方向!

Hor*_*hiv 18 iphone uikit uidevice uiinterfaceorientation device-orientation

嗨,我有一个应用程序,我有两个*.pngs默认闪屏:

Default-Landscape.png Default-Portrait.png

我想要的是在我的应用程序加载并准备好时,将此默认启动画面设置为动画.

为了达到这个目的,我通常会使用默认横向或默认纵向(取决于设备方向)呈现UIImageView,将其保留在屏幕上一段时间,然后将其设置为动画.

我的问题是,如果我呼吁[[UIDevice currentDevice] orientation]

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    
Run Code Online (Sandbox Code Playgroud)

答案始终是设备处于纵向方向,即使我清楚地将其置于风景中.我在模拟器和设备上尝试了这个,行为是一样的.

有没有人知道这个或其他方法的解决方案?

谢谢!

Ric*_*erg 5

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

只是为了澄清我的用法:

bgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:SplashImage]];
bgView.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
bgView.contentMode = UIViewContentModeTop;
Run Code Online (Sandbox Code Playgroud)


tob*_*yer 1

也许您可以在开始时显示一个带有黑色背景的空白视图,然后放入[[UIDevice currentDevice] orientation]该视图中viewDidAppear,然后从那里开始启动画面?