2012-05-07 12 views
1

OpenGLのゲームでは、デバイスの向き(縦向きと横向き)を意識する必要があります。iOS:デバイスの向きが起動後に決して到着しない

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は、ゲームのプレイ中に電話をどれだけ回転させても、再び呼び出されることはありません。

これが起こるにはどうしたらいいですか?

答えて

3

これはちょっと恥ずかしいです...

ポートレートモードのロックがオンになっています。

DOH!

関連する問題