UIDeviceOrientationDidChangeNotification仅触发一次
|
我正在尝试在其中一个视图的视图控制器上处理设备方向更改。
这是我的代码:
- (void)viewDidLoad {
[super viewDidLoad];
NSLog(@\"viewDidLoad\");
// Tell the UIDevice to send notifications when the orientation changes
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationChanged:) name:UIDeviceOrientationDidChangeNotification object:nil];
}
// tell the director that the orientation has changed
- (void) orientationChanged:(NSNotification *)notification
{
NSLog(@\"orientationChanged\");
}
当我第一次启动该应用程序时,会调用directionChanged选择器,但是此后无论我旋转iPad多少都不会再次调用它。有人知道我在做什么错吗?当我在应用程序委托中放置类似的代码时,它可以正常工作,但是在此特定的视图控制器中,它的行为不正确。
没有找到相关结果
已邀请:
2 个回复
蹄寄噬非芹
处理设备旋转。 我还遇到了
不触发的问题(它在模拟器中工作正常,但在我的设备上不工作)。经过一番调试后,我意识到我的设备锁定了“人像方向”功能,这导致“ 1”无法触发。不确定这是否是您的问题,但是这很容易忽略并且值得检查。
孝箱捆讨
其中界面方向是系统要使用的方向,但是您必须返回YES或它不会改变。 如果您未返回YES,则您的方向不会改变,因此您不会收到有关方向改变的通知(因为它没有发生)