【发布时间】:2014-06-14 11:49:30
【问题描述】:
我的 Storybuilder 采用纵向布局设计。当我在 iPad 已转为水平状态的情况下启动应用程序时,它能够正确检测到它处于水平位置。但是当我以纵向位置的 iPad 启动应用程序时,它认为它是水平的。但是,每次我旋转它时,代码都能正确检测到正确的方向。
- (void) viewDidLoad
{
[self updateForOrientation];
}
- (void)updateForOrientation
{
if (UIInterfaceOrientationIsPortrait([[UIDevice currentDevice] orientation])) // became portrait
{
NSLog(@"is portrait");
//code for changing layout to portrait position
}
else //became horiztontal
{
NSLog(@"is horizontal");
//code for changing layout to horizontal position
}
}
Output: is horizontal (this is the output whether it starts up as portrait or landscape)
【问题讨论】:
标签: ios ipad rotation orientation landscape-portrait