2010-12-30 21 views
0

私のアプリケーションで怒っている問題があります。私のアプリケーションでは、シミュレータをランドスケープモードに回転しますが、私の下の機能では、私は縦向きになります。向きが間違っています

ここで問題は何ですか?私を助けてください。

-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    if (interfaceOrientation == UIInterfaceOrientationPortrait || 
    interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) 
    { 
    NSLog(@" portrait orientation"); 
    } 
    else 
    { 
    NSLog(@"Landscape"); 
    } 
return YES; 
} 
+0

使用しているsdkとxcodeのバージョンを更新してください。同じコードを実行すると、期待される結果が得られます。おそらくあなたのxcodeにはいくつかの問題があります。 –

答えて

0

なぜあなたはBOOL値を返しませんでしたか? YESまたはNOを入力してOSに、対応する方向イベントを処理することを伝えます。

1

まず姿勢値がメソッド今setTheOrientation方法でブール値に応じて、必要な座標の値を設定する。

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 
// Overriden to allow any orientation. 
NSLog(@"shouldAutorotateToInterfaceOrientation called..."); 
if (interfaceOrientation == UIInterfaceOrientationPortrait || interfaceOrientation == UIDeviceOrientationPortraitUpsideDown) 
     defaultOrientation = 0; 
    else if(interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight) 
     defaultOrientation = 1; 
    [self setTheOrientation]; 
    return YES; 

}

で設定

1

方法がBOOLを返し、あなたはポートレートモードをしたい場合は、クラウズ場合にTRUEリターンを追加し、景観を望む場合は、他のクラウズにTRUEリターンを追加YESまたはNO

+0

申し訳ありません..これはtypo..whatですが、私のシミュレータは横向きモードですが、私はポートレートの向きが表示されます..何か助けを借ります – user198725878

+0

本当に面白いですが、私はなぜあなたはデバッグしてみましたか? interfaceOrientationには何が印刷されますか? – vodkhang

+0

NSLog(@ "%d"、interfaceOrientation)を試してみてください。 – vodkhang

0

のいずれかを返すことがあり、両方のモードが必要な場合は、shouldAutoRotateクラスルームにreturn TRUEと入力してください

関連する問題