嗨,我有这个代码...

- (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测试旋转之前的接口是如何的,还是我缺少某些东西?

谢谢你的帮助。

有帮助吗?

解决方案

请注意,该方法被命名为recrotate界面方向,因此自然而然 interfaceOrientation 参数包含旧方向,而不是新方向。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top