0

当设备向右旋转时,我想禁用按钮 myButton 。我设置了一个 if 块以在旋转时隐藏按钮,但设备无法识别它已被旋转。当我运行模拟并旋转模拟器时,我的 NSLog 语句显示为 false。为什么要这样做?

UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];
NSLog(orientation == UIInterfaceOrientationLandscapeLeft?@"true":@"false");

if([[UIDevice currentDevice] orientation]  == UIInterfaceOrientationLandscapeLeft)
{
   [myButton setHidden:YES];
}
4

1 回答 1

2
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft )
{
     [myButton setHidden:YES];
}

return interfaceOrientation;
}

祝你好运......

于 2012-08-14T05:59:48.317 回答