【发布时间】:2012-02-07 15:08:13
【问题描述】:
我想在 iPad 应用程序中显示启动画面。在此之前,我想获得当前的设备方向横向或纵向模式。我用过,
UIInterfaceOrientation orientation= [[UIApplication sharedApplication] statusBarOrientation];
if (orientation == UIInterfaceOrientationLandscapeRight || orientation == UIInterfaceOrientationLandscapeLeft)
{
splachview=[[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 1024, 768)];
splachview.image=[UIImage imageNamed:@"Default-Landscape.png"];
splachview.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
splachview.contentMode = UIViewContentModeTop;
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:NO];
[self.window addSubview:splachview];
}
else if (orientation == UIInterfaceOrientationPortrait || orientation == UIInterfaceOrientationPortraitUpsideDown)
{
splachview=[[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 768, 1024)];
splachview.image=[UIImage imageNamed:@"Default-Portrait.png"];
splachview.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
splachview.contentMode = UIViewContentModeTop;
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:NO];
[self.window addSubview:splachview];
}
在Appdelegate.m 中。 UIInterface 方向始终仅在纵向模式下检测。我在横向模式下启动了应用程序,但控件始终只检测纵向模式。如何在AppDelegate.m 中获取当前方向?请帮助我找到解决方案。提前致谢。
【问题讨论】:
标签: ios ipad splash-screen uiinterfaceorientation