当设备向右旋转时,我想禁用按钮 myButton 。我设置了一个 if 块以在旋转时隐藏按钮,但设备无法识别它已被旋转。当我运行模拟并旋转模拟器时,我的 NSLog 语句显示为 false。为什么要这样做?
UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];
NSLog(orientation == UIInterfaceOrientationLandscapeLeft?@"true":@"false");
if([[UIDevice currentDevice] orientation] == UIInterfaceOrientationLandscapeLeft)
{
[myButton setHidden:YES];
}