联系客服:400-805-1963

ios6.0和6.0以下横竖屏幕转换问题处理
更新:HHH   时间:2023-1-7


设计师给的需求设计上添加了一个页面要横屏显示

本以为解决起来不是问题,没想到ios5下,这个问题就已经是个问题,因为页面设计上新页面出现是push进来的。
而苹果会让push进来的页面显示为原来屏幕的旋转度,这样会让整个view变形(已经说不清楚,话说以后有问题还是
发个博客一步步来解决比较好,可以随时截屏
)
 
 
 

突然不想说了参考了

iPhone开发之-横竖屏 切换push

http://blog.sina.com.cn/s/blog_7cac8562010112ch.html

赶时间了,不细细说了

解决方案是:

 

  1. // 
  2. //  MNViewController.m 
  3. //  LeeDemoProject 
  4. // 
  5. //  Created by mobilenow03 on 12-10-29. 
  6. //  Copyright (c) 2012年 mobilenow03. All rights reserved. 
  7. // 
  8.  
  9. #import "SecondVC.h" 
  10. #import <QuartzCore/QuartzCore.h> 
  11. @interface SecondVC () 
  12.  
  13. @end 
  14.  
  15. @implementation SecondVC 
  16. @synthesize _imgVBackground,_vTransform; 
  17. - (void)dealloc { 
  18.     [_imgVBackground release]; 
  19.     [_vTransform release]; 
  20.     [super dealloc]; 
  21. } 
  22. - (void)viewDidLoad 
  23. { 
  24.     [super viewDidLoad]; 
  25.     // Do any additional setup after loading the view, typically from a nib. 
  26. //    [UIView beginAnimations:nil context:nil]; 
  27. //     
  28. //    [UIView setAnimationDuration:0.3]; 
  29.      
  30.     //设置导航栏旋转 
  31.      
  32.     self.navigationController.navigationBarHidden = YES; 
  33.      
  34.      
  35.      
  36. } 
  37. - (id)init 
  38. { 
  39.     self = [super init]; 
  40.     if (self) 
  41.     { 
  42.          
  43. //        [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications]; 
  44. //        [[NSNotificationCenter defaultCenter] addObserver:self 
  45. //                                                 selector:@selector(orientationChanged:) 
  46. //                                                     name:UIDeviceOrientationDidChangeNotification 
  47. //                                                   object:nil]; 
  48.     } 
  49.     return self; 
  50. } 
  51.  
  52.  
  53. -(void)viewDidUnload 
  54. { 
  55.     [self set_vTransform:nil]; 
  56.     [super viewDidUnload]; 
  57. } 
  58.  
  59. -(void)viewWillAppear:(BOOL)animated 
  60. { 
  61.     [super viewWillAppear:animated]; 
  62.     self.view.bounds = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height); 
  63.      
  64.     self.view.transform = CGAffineTransformMakeRotation( M_PI*1.5); 
  65. //    if ([[UIDevice currentDevice].systemVersion floatValue] >= 6.0) { 
  66. //        self.view.bounds = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height); 
  67. //         
  68. //        self.view.transform = CGAffineTransformMakeRotation(-M_PI*1.5); 
  69. //    }else 
  70. //    { 
  71. //        [[UIApplication sharedApplication] setStatusBarOrientation: UIInterfaceOrientationLandscapeRight animated: YES]; 
  72. //        CGFloat duration = [UIApplication sharedApplication].statusBarOrientationAnimationDuration; 
  73. //        [UIView beginAnimations:nil context:nil]; 
  74. //        [UIView setAnimationDuration:duration]; 
  75. //        self.navigationController.view.transform = CGAffineTransformIdentity; 
  76. //        self.navigationController.view.transform = CGAffineTransformMakeRotation(M_PI*(90)/180.0); 
  77. //        self.navigationController.view.bounds = CGRectMake(0, 0, 480, 320); 
  78. //        [UIView commitAnimations];   
  79. //    } 
  80.      
  81. //    [[NSNotificationCenter defaultCenter] postNotificationName:@"OnlyLandscape" object:@"SecondVC"]; 
  82. //    CGFloat angle = 90; 
  83. //    self._vTransform.layer.transform = CATransform3DMakeRotation(angle*M_PI/180.0, 0, 0.0, 1.0); 
  84.     //设置旋转动画 
  85.      
  86.      
  87. //    self.navigationController.navigationBar.transform = CGAffineTransformMakeRotation(M_PI*1.5); 
  88. //     
  89. //    //设置视图旋转 
  90. //     
  91. //    self.view.bounds = CGRectMake(0, -54, self.view.frame.size.width, self.view.frame.size.height); 
  92. //     
  93. //    self.view.transform = CGAffineTransformMakeRotation(-M_PI*1.5); 
  94. //     
  95. //    [UIView commitAnimations]; 
  96.  
  97. } 
  98. - (void)didReceiveMemoryWarning 
  99. { 
  100.     [super didReceiveMemoryWarning]; 
  101.     // Dispose of any resources that can be recreated. 
  102. } 
  103.  
  104. // 大头贴的测试环境下 
  105. - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)orientation 
  106. { 
  107. //    if ((orientation == UIInterfaceOrientationPortrait) || 
  108. //        (orientation == UIInterfaceOrientationLandscapeLeft)) 
  109. //        return YES; 
  110. //    if ((orientation == UIInterfaceOrientationLandscapeRight) || 
  111. //        (orientation == UIInterfaceOrientationLandscapeLeft)) 
  112. //        return YES; 
  113. //    else 
  114.         return NO; 
  115.  
  116. } 
  117.  
  118.  
  119. //-(BOOL)shouldAutorotate 
  120. //{ 
  121. //    return YES; 
  122. //} 
  123. - (IBAction)backBtnClicked:(id)sender { 
  124. //    if ([[UIDevice currentDevice].systemVersion floatValue] >= 6.0) { 
  125. //    }else 
  126. //    { 
  127. //        [[UIApplication sharedApplication] setStatusBarOrientation: UIInterfaceOrientationLandscapeRight animated: YES]; 
  128. //        CGFloat duration = [UIApplication sharedApplication].statusBarOrientationAnimationDuration; 
  129. //        [UIView beginAnimations:nil context:nil]; 
  130. //        [UIView setAnimationDuration:duration]; 
  131. //        self.navigationController.view.transform = CGAffineTransformIdentity; 
  132. //        self.navigationController.view.transform = CGAffineTransformMakeRotation(M_PI*(0)/180.0); 
  133. //        self.navigationController.view.bounds = CGRectMake(0, 0, 320, 480); 
  134. //        [UIView commitAnimations]; 
  135. //    } 
  136.     [self.navigationController popToRootViewControllerAnimated:YES]; 
  137. } 
  138.  
  139. //-(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation 
  140. //{ 
  141. //    if (fromInterfaceOrientation == UIInterfaceOrientationMaskLandscape) { 
  142. //        NSLog(@"从横屏"); 
  143. //    }else if (fromInterfaceOrientation == UIInterfaceOrientationMaskPortrait) { 
  144. //        NSLog(@"从肃屏"); 
  145. //    } 
  146. //} 
  147.  
  148. //-(NSUInteger)supportedInterfaceOrientations 
  149. //{ 
  150. //    return UIInterfaceOrientationMaskLandscape; 
  151. //} 
  152.  
  153. //static bool is = NO; 
  154. //- (void)orientationChanged:(NSNotification *)notification 
  155. //{ 
  156. //    UIDeviceOrientation deviceOrientation = [UIDevice currentDevice].orientation; 
  157. //    switch (deviceOrientation) { 
  158. //        case UIDeviceOrientationPortrait: 
  159. //        { 
  160. //             
  161. //        } 
  162. //            break; 
  163. //        case UIDeviceOrientationLandscapeLeft: 
  164. //        { 
  165. //             
  166. //        } 
  167. //            break; 
  168. //        case UIDeviceOrientationPortraitUpsideDown: 
  169. //        { 
  170. //             
  171. //        } 
  172. //            break; 
  173. //        case UIDeviceOrientationLandscapeRight: 
  174. //        { 
  175. //            if (!is) { 
  176. //                //self._imgVBackground.frame = CGRectMake(0, 0, 480, 320); 
  177. ////                self.view.bounds = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height); 
  178. //                 
  179. //                self.view.transform = CGAffineTransformMakeRotation(M_PI*0.5); 
  180. //                is = YES; 
  181. //            } 
  182. //             
  183. //        } 
  184. //            break; 
  185. //             
  186. //        default: 
  187. //            break; 
  188. //    } 
  189. //} 
  190.  
  191. //-(void) 
  192. @end 

 

返回移动开发教程...