0

アプリケーションに問題があり、気が狂います。私のアプリケーションでは、シミュレーターを横向きモードに回転させますが、以下の関数では、縦向きになります。

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

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

4 に答える 4

1

最初に向きの値を設定する方法です

- (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;

}

setTheOrientation メソッドのブール値に従って、必要な座標の値を設定します。

于 2010-12-30T06:48:47.817 に答える
1

メソッドは BOOL を返します。YES または NO を返す必要があります。

于 2010-12-30T06:53:19.360 に答える
0

なぜBOOL値を返さなかったのですか?YESまたはNOは、対応するオリエンテーションイベントを処理することをOSに通知します。

于 2010-12-30T06:41:15.620 に答える
0

縦向きモードが必要な場合は、 if clouseに return TRUE を追加し、横向きが必要な場合は、 else clouseに return TRUE を追加します。両方のモードが必要な場合は、shouldAutoRotate clouse に return TRUE と入力します。

于 2010-12-30T06:53:22.477 に答える