如何在自定义的iPhone应用程序中从垂直向水平视图旋转

问题描述:

我有一个视图控制器,其中包含一个图形视图和分段控制。如何使视图旋转到水平?另外,是否可以加载另一个水平方向的视图?旋转时如何在自定义的iPhone应用程序中从垂直向水平视图旋转

- (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation 
{ 
// Just delete the lines for the orientations you don't want to support 
    if((toInterfaceOrientation == UIInterfaceOrientationPortrait) || 
    (toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)) || 
    (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft)) || 
    (toInterfaceOrientation == UIInterfaceOrientationLandscapeRight)) { 
    return YES; 
    } 
return NO; 
} 

然后加载新的视图控制器:

Thx提前, 姆拉登

您实现定向支持通过

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation 
{ 
    if((fromInterfaceOrientation == UIInterfaceOrientationLandscapeLeft) || 
    (fromInterfaceOrientation == UIInterfaceOrientationLandscapeRight)) 
    {  
    // Load the view controller you want to display in portrait mode... 
    } 
} 

你甚至可以建立一个动画操纵新视图的alpha属性,如果你想做一个平滑过渡,就像你在iPod应用中看到的那样,当它转换到Cover流量模式。

免责声明 支持界面旋转的首选方法更改为3.0。上述方法仍然有效,但有一种方法可以获得更流畅的动画。但我们不应该在这里谈论这一点。更多。周。

ANOTHERvDISCLAIMER 支持接口旋转的首选方法在6.0中再次发生变化。上述方法仍然有效,但有一种方法可以获得更流畅的动画。

对于设备旋转你应该实现在您的viewController这个方法:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation