私のアプリはopenGLですが、これを処理する方法は通知を使用することでした:
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return YES;
}
// This is called right BEFORE the view is about to rotate. Here I'm using a notification message
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
if (UIInterfaceOrientationIsPortrait(toInterfaceOrientation)) {
NSNotification* notification = [NSNotification notificationWithName:@"orientationIsPortrait" object:self];
[[NSNotificationCenter defaultCenter] postNotification:notification];
}
else {
NSNotification* notification = [NSNotification notificationWithName:@"orientationIsLandscape" object:self];
[[NSNotificationCenter defaultCenter] postNotification:notification];
}
}
willRotateToInterfaceOrientation は、実際に向きの回転を開始する直前に呼び出されます。
次に、EAGLView initWithFrame: オブザーバーを設定します。
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(viewBecamePortrait:) name:@"orientationIsPortrait" object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(viewBecameLandscape:) name:@"orientationIsLandscape" object:nil];
viewBecamePortrait と viewBecameLandscape では、変更をプログラムで処理します。