只含有 。关于横竖屏的代码

#import "InspectionReportViewController.h"

#define SCREEN_WIDTH ([UIScreen mainScreen].bounds.size.width)

#define SCREEN_HEIGHT ([UIScreen mainScreen].bounds.size.height)
@interface InspectionReportViewController ()<UIWebViewDelegate>
{
UIWebView *webview; UIButton * back; }
@end @implementation InspectionReportViewController -(BOOL)shouldAutorotate{ return NO;
} - (UIInterfaceOrientationMask)supportedInterfaceOrientations
{
// 如果该界面需要支持横竖屏切换
return UIInterfaceOrientationMaskLandscapeRight | UIInterfaceOrientationMaskPortrait;
// 如果该界面仅支持横屏
// return UIInterfaceOrientationMaskLandscapeRight;
} -(void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated]; }
-(void)viewWillDisappear:(BOOL)animated{
[super viewWillDisappear:animated]; } - (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view. [self CreatUI]; //横屏同志UIApplicationDidChangeStatusBarFrameNotification UIDeviceOrientationDidChangeNotification
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(deviceOrientationDidChange) name:UIDeviceOrientationDidChangeNotification object:nil];
} -(void)CreatUI{ self.view.backgroundColor = [UIColor blackColor]; webview = [[UIWebView alloc] initWithFrame:self.view.bounds];
webview.backgroundColor = [UIColor blackColor]; [webview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://60.205.188.204:8087/WebDcmviewer/dcmviewer.html?org_code=%@&check_id=%@",_org_code,_check_id]]]]; webview.scalesPageToFit = YES;
webview.scrollView.scrollEnabled = NO;
[self.view addSubview:webview]; back = [myButton buttonWithType:UIButtonTypeCustom frame:CGRectMake(ScreenWidth-IPHONEWIDTH(), ScreenHeight-IPHONEHIGHT(), IPHONEWIDTH(), IPHONEHIGHT()) tag: image:@"ic_history_ct_return" andBlock:^(myButton *button) { [self.navigationController popViewControllerAnimated:YES]; }]; [self.view addSubview:back]; } //横屏
- (void)deviceOrientationDidChange
{
NSLog(@"deviceOrientationDidChange:%ld",(long)[UIDevice currentDevice].orientation); if([UIDevice currentDevice].orientation == UIDeviceOrientationPortrait) { [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait]; [UIView animateWithDuration:0.1f animations:^{ self.view.transform = CGAffineTransformMakeRotation();
self.view.bounds = CGRectMake(, , SCREEN_WIDTH, SCREEN_HEIGHT); webview.frame = self.view.bounds; back.frame = CGRectMake(SCREEN_WIDTH-IPHONEWIDTH(), SCREEN_HEIGHT-IPHONEHIGHT(), IPHONEHIGHT(), IPHONEHIGHT()); }]; //注意: UIDeviceOrientationLandscapeLeft 与 UIInterfaceOrientationLandscapeRight
} else if ([UIDevice currentDevice].orientation == UIDeviceOrientationLandscapeLeft ) { [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight]; [UIView animateWithDuration:0.1f animations:^{ self.view.transform = CGAffineTransformMakeRotation(M_PI_2); self.view.bounds = CGRectMake(, , SCREEN_HEIGHT, SCREEN_WIDTH); webview.frame = self.view.bounds; back.frame = CGRectMake(SCREEN_WIDTH-IPHONEWIDTH(), SCREEN_HEIGHT-IPHONEHIGHT(), IPHONEHIGHT(), IPHONEHIGHT()); }]; }else if ( [UIDevice currentDevice].orientation== UIDeviceOrientationLandscapeRight){ [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeLeft]; [UIView animateWithDuration:0.1f animations:^{ self.view.transform = CGAffineTransformMakeRotation(-M_PI_2); self.view.bounds = CGRectMake(, ,SCREEN_HEIGHT, SCREEN_WIDTH); webview.frame = self.view.bounds; back.frame = CGRectMake(SCREEN_WIDTH-IPHONEWIDTH(), SCREEN_HEIGHT-IPHONEHIGHT(), IPHONEHIGHT(), IPHONEHIGHT()); }];
}
} /*
#pragma mark - Navigation // In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/ @end

最新文章

  1. 从SQLite获取数据完成一个产品信息展示
  2. Swift - 文本输入框(UITextField)
  3. iOS UITableViewCell 中 调整imageView 的图片大小
  4. Mars 是微信官方的终端基础组件,是一个使用 C++ 编写的业平台性无关的基础组件
  5. Linux下配置安装PHP环境
  6. jQuery API 3.1.0 速查表-打印版
  7. Application.CommonAppDataPath的路径
  8. 用javascript操作xml(三)关于Jquery的html()不兼容IE的解决办法
  9. jMeter之二
  10. cf A. Down the Hatch!
  11. Android ListView SimpleAdapter支持Bitmap类型图片显示
  12. MyEclipse中将项目导出jar包,以及转化成EXE文件
  13. css+html菜单适应性学习的宽度
  14. leetcode 第42题 Multiply Strings
  15. Linux Apache2 配置介绍
  16. Java枚举:小小enum,优雅而干净
  17. golang命令行参数
  18. Coursera, Deep Learning 4, Convolutional Neural Networks - week1
  19. 获取微信小程序源码
  20. php中文转拼音2

热门文章

  1. 使用Gulp构建前端自动化方案
  2. ThinkPHP中的Model模型
  3. linux磁盘管理系列-LVM的使用
  4. 迭代操作--&gt;c:forEach和c:forTokens
  5. Delphi 7中对StretchBlt, StretchDIBits, DrawDibDraw, BitBlt 的性能测试 - 原创
  6. Uncaught TypeError: download is not a function at HTMLAnchorElement.onclick (index.html:25)
  7. Python函数篇(3)-内置函数、文件处理
  8. 基于Spring Aop实现类似shiro的简单权限校验功能
  9. 程序员的自我救赎---3.1:理解Oauth2.0
  10. 洛谷 P3928 Sequence