简体   繁体   English

iPhone-接口方向颠倒了吗?

[英]iPhone - Interface Orientation reversed?

Hi I have this piece of code... 嗨,我有这段代码...

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

and

- (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?
  }
}

as you see, the code is running in reverse, I mean, the part the should run when I change the device to portrait, the landscape part of the code runs and vice-versa. 如您所见,代码是反向运行的,我的意思是,当我将设备更改为纵向时,应该运行的部分,代码的横向部分运行,反之亦然。

WHen I turn the device, self.view rotates. 当我转动设备时,self.view旋转。

is this UIInterfaceOrientationIsPortrait testing how the interface is before the rotation or am I missing something? UIInterfaceOrientationIsPortrait是在旋转之前测试界面的状态还是我错过了一些东西?

thanks for any help. 谢谢你的帮助。

请注意,该方法被命名为didRotate InterfaceOrientation,所以自然interfaceOrientation参数包含旧方向,而不是新的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM