デバイスの向き(つまり、縦向きと横向き)を認識する必要があるOpenGLゲームがあります。
APIは非常に単純なようです...私のViewControllerの関連部分は次のとおりです。
@implementation MyViewController
- (id)init
{
...
// Get orientation events
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(didRotate:)
name:@"UIDeviceOrientationDidChangeNotification" object:nil];
...
}
-(void)didRotate:(NSNotification*)notification
{
NSLog(@"didRotate %d", orientation);
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)orientation
{
NSLog(@"shouldAutorotateToInterfaceOrientation %d", orientation);
return YES;
}
@end
何が起こるかというと、起動中にいくつかの呼び出しがあります。
shouldAutorotateToInterfaceOrientation 3
shouldAutorotateToInterfaceOrientation 3
shouldAutorotateToInterfaceOrientation 3
shouldAutorotateToInterfaceOrientation 3
didRotate 4
shouldAutorotateToInterfaceOrientation 4
shouldAutorotateToInterfaceOrientation 4
didRotate 1
shouldAutorotateToInterfaceOrientation 1
その後、UIViewとEAGLContextが設定され、レンダリングが開始され、すべてが見栄えが良くなりますが、ゲームのプレイ中に電話をどれだけ回転させても、shouldAutorotateToInterfaceOrientationとdidRotateが再度呼び出されることはありません。
これが起こるために私は何を間違っている可能性がありますか?