2012-08-09 39 views
1

在我的RootViewController的shouldAutorotateToInterfaceOrientation方法,我重新实现的方法shouldAutorotateToInterfaceOrientation这样。IOS开发 - 不要求肖像模式

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation { 
    switch (toInterfaceOrientation) { 
     case UIInterfaceOrientationPortrait: 
      NSLog(@"Orientation - Portrait"); 
      break; 
     case UIInterfaceOrientationLandscapeLeft:   
      NSLog(@"Orientation - Left"); 
      break; 
     case UIInterfaceOrientationLandscapeRight: 
      NSLog(@"Orientation - Right"); 
      break; 
     case UIInterfaceOrientationPortraitUpsideDown: 
      NSLog(@"Orientation - UpsideDown"); 
      break; 
     default: 
      break; 
    } 
    return YES; 
} 

当我旋转我的设备时,此方法为LandscapeRight,LandscapeLeft和UpsideDown调用,但不适用于纵向。

在发起视图处于纵向模式时,这种方法被调用UIInterfaceOrientationPortrait。但是当我旋转设备时,这种方法不仅仅被称为这个方向。

回答

0

shouldAutorotateToInterfaceOrientation通常只叫一次,告诉来电者,有什么方位的应用程序将支持(一个或运算值或者是所有)。你可能会寻找willRotateToInterfaceOrientation:duration:检查取向和/或显示新的方向之前,做一些重排。

+0

我想旋转在我的主视图中央的UIImageView不旋转的所有接口。 – Steven 2012-10-06 18:37:36