使用此代码按下按钮时,我正在检查设备是处于横向模式还是纵向模式:
orientation = [[UIApplication sharedApplication]statusBarOrientation];
- (void)buttonclick
{
if (orientation == UIInterfaceOrientationPortrait)
{
NSLog(@"port");
}
else
{
NSLog(@"Land");
}
}
在这种情况下,它记录着陆地,甚至认为模拟器处于纵向模式。怎么了?
答案 0 :(得分:1)
您应该在方法中设置orientation
:
- (void)buttonClick {
orientation = [[UIApplication sharedApplication] statusBarOrientation];
if (orientation == UIInterfaceOrientationPortrait)
{
NSLog(@"port");
}
else
{
NSLog(@"Land");
}
}