0

我在用

[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(detectOrientation) name:@"UIDeviceOrientationDidChangeNotification" object:nil];

对我的 appdelegate 中的某些视图进行更改。

但这会在加速度计的最轻微变化中被调用。任何人都可以提出任何解决方法,以便仅在设备完全旋转时才调用它。谢谢

4

2 回答 2

1

您能否在发布通知之前编写一些代码来检查设备的宽度 = 480 和高度 = 320(这是设备旋转 90 度时)?

所以像:

[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];

...

if(width == 480 && height == 320)
{
    [[NSNotificationCenter defaultCenter] postNotification . . . ];
}
于 2011-07-28T06:27:04.830 回答
0
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
     //your code here
}

在您的视图控制器中覆盖此方法。当设备旋转到新方向时会调用它

于 2011-07-28T04:24:57.253 回答