温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

ios6.0和6.0以下横竖屏幕转换问题处理

发布时间:2020-05-27 12:33:22 来源:网络 阅读:1491 作者:xinji0702 栏目:移动开发
设计师给的需求设计上添加了一个页面要横屏显示

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

 

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI