iPhone - 界面定位是否逆转?

Spa*_*Dog 1 iphone iphone-sdk-3.0 ipad

嗨,我有这段代码......

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return YES;
}
Run Code Online (Sandbox Code Playgroud)

- (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?
  }
}
Run Code Online (Sandbox Code Playgroud)

如你所见,代码反向运行,我的意思是,当我将设备更改为纵向时应该运行的部分,代码的横向部分运行,反之亦然.

当我转动设备时,self.view会旋转.

这个UIInterfaceOrientationIsPortrait是在旋转之前测试界面的方式还是我错过了什么?

谢谢你的帮助.

Ole*_*ann 6

请注意,该方法 InterfaceOrientation 命名为didRotate ,因此interfaceOrientation参数自然包含旧方向,而不是新方向.