2011-08-05 97 views
1

我使用IF语句来检测设备的方向何时发生更改以及何时发生,会显示一个新视图,一个肖像,另一个环境。唯一的问题是,如果我从肖像旋转到风景,并且风景视图显示,它并未一直旋转。它仍然是肖像,它应该是90度。谢谢你的帮助!视图不能正确旋转

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration { 

    if (toInterfaceOrientation == UIInterfaceOrientationPortrait || toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) { 
     //portrait 

     self.view = portrait; 


    } else { 
     //landscape 

     self.view = landscape; 

    } 

} 

回答

1

从苹果为此here提供示例代码。

+0

完美,谢谢! –

0

您可能能够通过willRotateToInterfaceOrientation期间存储目的地的方向,然后推新视图之后就didRotateFromInterfaceOrientation解决它。

+0

好吧,那我该怎么做?类似于self.view = UIInterfaceOrientationPortrait || UIInterfaceOrientationPortraitUpsideDown等?谢谢你的帮助! –