Iphone Xcode方向属性不返回当前方向

Iphone Xcode方向属性不返回当前方向,iphone,xcode,button,orientation,hide,Iphone,Xcode,Button,Orientation,Hide,当设备向右旋转时,我想禁用按钮myButton。我设置了一个if块来隐藏旋转时的按钮,但设备无法识别它是否已旋转。运行模拟并旋转模拟器时,我的NSLog语句显示false。为什么要这样做 UIDeviceOrientation方向=[[UIDevice currentDevice]方向]; NSLog(方向==UIInterfaceOrientationAndscapeLeft?@“真”:@“假”); if([[UIDevice currentDevice]方向]==UIInterfaceOri

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

UIDeviceOrientation方向=[[UIDevice currentDevice]方向];
NSLog(方向==UIInterfaceOrientationAndscapeLeft?@“真”:@“假”);
if([[UIDevice currentDevice]方向]==UIInterfaceOrientationAndscapeLeft)
{
[myButton setHidden:是];
}

祝你好运……

所以我用以下方法测试了我的视图:NSLog(UIDeviceOrientationIsValidInterfaceOrientation([UIDevice currentDevice].orientation)@“true”:@“false”);我一直在变假。什么会导致方向无效?
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft )
{
     [myButton setHidden:YES];
}

return interfaceOrientation;
}