ios UITabBarController iOS5,iOS6,旋转需要写两个

在iOS6下shouldAutorotateToInterfaceOrientation被弃用,现在iOS6下有三个新方法处理屏幕旋转:

  1. // 是否支持屏幕旋转  
  2. - (BOOL)shouldAutorotate {  
  3.     return YES;  
  4. }  
  5. // 支持的旋转方向  
  6. - (NSUInteger)supportedInterfaceOrientations {  
  7.     return UIInterfaceOrientationMaskAllButUpsideDown;//UIInterfaceOrientationMaskAllButUpsideDown;  
  8. }  
  9. // 一开始的屏幕旋转方向  
  10. - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {  
  11.     return UIInterfaceOrientationPortrait;  


一、在info.plist的“Supported interface orientations”添加支持的旋转方向,这个必须有,决定了旋转支持的最多方向;

二、将AppDelegate的[self.window addSubview:navigationController.view]; 改为self.window.rootViewController = navigationController; 或者[self.window addSubview:tabBarController.view]; 改为self.window.tabBarController;

原文地址:https://www.cnblogs.com/li-baibo/p/3169596.html