ios7横竖屏适配

  1. * 
  2.  *  根据当前屏幕方向,重新定义view的frame 
  3.  * 
  4.  *  @param orientation 屏幕方向 
  5.  * 
  6.  *  @return 适配后的frame 
  7.  */  
  8. - (CGRect)frameForOrientation:(UIInterfaceOrientation)orientation  
  9. {  
  10.     CGRect frame;  
  11.     if (orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight) {  
  12.         CGRect bounds = [UIScreen mainScreen].bounds;  
  13.         frame = CGRectMake(bounds.origin.x, bounds.origin.y, bounds.size.height, bounds.size.width);  
  14.     } else {  
  15.         frame = [UIScreen mainScreen].bounds;  
  16.     }  
  17.     return frame;  
  18. }  
[objc]  view plain copy 在CODE上查看代码片 派生到我的代码片
  1.   
[objc]  view plain copy 在CODE上查看代码片 派生到我的代码片
  1. <pre code_snippet_id="113410" snippet_file_name="blog_20131215_3_2421970" name="code" class="objc">//ios7  
  2. - (BOOL)shouldAutorotate  
  3. {  
  4.     return YES;  
  5. }  
  6. //支持的方向  
  7. - (NSUInteger)supportedInterfaceOrientations  
  8. {  
  9.     return UIInterfaceOrientationMaskAll;  
  10. }  
  11.   
  12. - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation  
  13. {  
  14.     return YES;  
  15. }  
  16.   
  17. - (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation duration:(NSTimeInterval)duration  
  18. {  
  19.     CGRect frame = [self frameForOrientation:interfaceOrientation];  
  20.     self.webView.frame = frame;//重新定义frame  
  21. }  
  22. </pre><br>  
  23. <br>  
  24. <pre></pre>  
  25. <p><br>  
  26. </p>  
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值