iOS 6以下横竖屏幕,在ViewController中重写方法
   
   
   
   
  1. -(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation{ 
  2.     // 系统宏定义只横屏幕 
  3.     return UIDeviceOrientationIsLandscape(toInterfaceOrientation); 
  4.     // 系统宏定义只竖屏幕 
  5.     return UIDeviceOrientationIsPortrait(toInterfaceOrientation); 
  6.     // 也可以自己实现只竖屏幕,home键在下面 
  7.     return (toInterfaceOrientation == UIDeviceOrientationPortrait); 
  8.     // 也可以自己实现只竖屏幕,home键在上面 
  9.     return (toInterfaceOrientation == UIDeviceOrientationPortraitUpsideDown); 
  10.     // 也可以自己实现只竖屏幕,home键在右面 
  11.     return (toInterfaceOrientation == UIDeviceOrientationLandscapeLeft); 
  12.     // 也可以自己实现只竖屏幕,home键在左面 
  13.     return (toInterfaceOrientation == UIDeviceOrientationLandscapeRight); 
  14.      
 
iOS 6以上,在AppDelegate中设置,设置后需要在Target》Summary》Support Interface Orientations设置屏幕,不设置相同的屏幕会导致闪退
   
   
   
   
  1. #if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_6_0 
  2. -(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window{ 
  3.  
  4.     // 竖屏home键在下面 
  5.     return UIInterfaceOrientationMaskPortrait; 
  6.     // 横屏home键在右边 
  7.     return UIInterfaceOrientationMaskLandscapeLeft; 
  8.     // 横屏home键在左边 
  9.     return UIInterfaceOrientationMaskLandscapeRight; 
  10.     // 竖屏home键在上面 
  11.     return UIInterfaceOrientationMaskPortraitUpsideDown; 
  12.     // 横屏 
  13.     return UIInterfaceOrientationMaskLandscape; 
  14.     // 四向翻转 
  15.     return UIInterfaceOrientationMaskAll; 
  16.     // 除竖屏,三向翻转 
  17.     return UIInterfaceOrientationMaskAllButUpsideDown; 
  18.      
  19. #endif