1

こんにちは私はこのコードを持っています...

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return YES;
}

- (void) didRotateFromInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{

  if(UIInterfaceOrientationIsPortrait(interfaceOrientation)){
    // WTF, this runs when I change to Landscape
  } else {
    // this runs when I change to Portrait??? shouldn't it be the contrary?
  }
}

ご覧のとおり、コードは逆に実行されています。つまり、デバイスをポートレートに変更したときに実行する必要がある部分、コードのランドスケープ部分が実行され、その逆も同様です。

デバイスを回転させると、self.viewが回転します。

このUIInterfaceOrientationIsPortraitは、回転前のインターフェイスの状態をテストしていますか、それとも何かが足りませんか?

助けてくれてありがとう。

4

1 に答える 1

6

メソッドの名前はdidRotateFromInterfaceOrientationであるため、当然、パラメーターには新しい方向ではなく古い方向が含まれることに注意してくださいinterfaceOrientation

于 2010-02-20T16:17:42.517 に答える