2012-08-09 38 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