我有一个视图控制器设定与一个图形视图和分段内的控制权。如何使视图旋转至水平的呢?此外,有可能加载另一个视图为水平取向?

Thx提前, 姆拉登纳莱

有帮助吗?

解决方案

您通过实施定向支持:

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

然后,以在旋转时加载新的ViewController:

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

您甚至可以建立一个动画来操纵新视图的alpha属性,如果你想做一个平滑的过渡,就像你在iPod应用程序时看到它转变到CoverFlow模式。

<强>声明 的在3.0支承界面旋转变化的优选方法。上面的方法仍然可以工作,但有一种方式来获得平滑的动画。但是,我们不应该在这里讨论了一个。更多。周。

<强> ANOTHERvDISCLAIMER 的支撑接口旋转的优选方法在6.0再次改变。上面的方法仍然可以工作,但有一种方式来获得平滑的动画。

其他提示

有关设备旋转你应该在你的viewController实现此方法:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation

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