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

#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

iOS 工程默认只允许竖屏,在单独界面进行横竖转换,屏幕旋转的更多相关文章

  1. iOS的横屏(Landscape)与竖屏(Portrait)InterfaceOrientation

    http://www.molotang.com/articles/1530.html 接着上篇写的触摸事件,这次借机会整理下iOS横屏和竖屏的翻转方向支持,即InterfaceOrientation相 ...

  2. iOS强制横屏或强制竖屏

    原文链接 https://www.jianshu.com/p/d6cb54d2eaa1 亲测第二种我这边是阔以滴 第一种解决方案(不推荐,直接跳过看第二种解决方案): //强制转屏 - (void)i ...

  3. Android和iOS中Cocos2dx的横屏竖屏设置

    一.横屏.竖屏设置 1.android AndroidManifest.xml文件中, screenOrientation="landscape" 为横屏, screenOrien ...

  4. iOS强制切换横屏、竖屏

    切换横竖屏最直接的方式是调用device的setOrientation方法.但是从sdk3.0以后,这个方法转为似有API,如果要上AppStore的话,要慎用! if ([[UIDevice cur ...

  5. iOS设置竖屏,播放视频可以任性旋转的解决方法,亲测可用

    之前在网上找了很多方法,都是强制横屏,但是如果设备关闭旋转锁定,强制横屏后把设备竖立起来,播放器也会跟着竖过来,但是就回不去了.现在项目要求让app默认都是竖屏,只有在全屏播放的时候可以自由旋转,于是 ...

  6. iOS 全局竖屏 单个viewcontroller点击按钮支持横屏

    问题描述:项目工程只支持竖屏,在播放器页面需要点击按钮进行横竖屏切换,并能根据手机的方向进行自动旋转 如图:只勾选了竖屏 解决方法:(主要是采用视图transform的原理 横屏时调整视频视图上的每个 ...

  7. 转载:Android横屏竖屏切换的问题

    一.禁止横竖屏转换 Android横竖屏切换在手机开发中比较常见,很多软件在开发过程中为了避免横竖屏切换时引发不必要的麻烦,通常禁止掉横竖屏的切换, 通过在AndroidManifest.xml中设置 ...

  8. Android4.0强制横屏竖屏

    Android的启动默认是横屏或者竖屏我们的TV本来是横屏显示,但是有客户竟然要竖屏显示,昨天快下班收到的需求,竟然说7.19就要搞定.思路有2个,一个就是修改LCD的默认输出,但是这个不是我这个水平 ...

  9. 关于Cocos2d-x手机上运行游戏的时候屏幕横屏改竖屏的解决方案

    cocos2d-x打包的时候默认是横屏,如果要改成竖屏,步骤如下: 1.打开项目 2.打开proj.android 3.编辑AndroidManifest.xml 4. 找到这一句android:sc ...

随机推荐

  1. 如何访问 Service?- 每天5分钟玩转 Docker 容器技术(99)

    前面我们已经学习了如何部署 service,也验证了 swarm 的 failover 特性.不过截止到现在,有一个重要问题还没有涉及:如何访问 service?这就是本节要讨论的问题. 为了便于分析 ...

  2. nomad的简易集群

    启动服务器 第一步是为服务器创建配置文件.无论是从下载的文件github,或粘贴到一个名为server.hcl: vim server.hcl # Increase log verbosity log ...

  3. jQuery操作input改变value属性值

    今天写了一个表单元素,在用户点击的时候会清空input中的内容,当鼠标点击其他地方的时候会把输入的值保存为input的value值 类似于这样的效果 当用户点击的时候文字消失. html代码 < ...

  4. 巧-微信公众号-操作返回键问题-angularjs开发 SPA

    在解决这个问题之前,一直处在很苦逼的状态,因为 现在绝大多数 前端模块都是 SPA 模式:所以由此而来出了许多的问题,当然我现在提的这个只是其中一个: 说一下解决方案: 1.技术栈 angularjs ...

  5. Resin4安装配置

    #Resin4安装配置 # Resin4安装配置 #centos6 #参考http://467754239.blog.51cto.com/4878013/1558435 #yum -y install ...

  6. GO学习——安装编译(1)

    学习网站列表: Golang官网:https://golang.org/ Golang标准库文档:https://golang.org/pkg Golang中文标准库文档:https://studyg ...

  7. Linux下编译memecaced

        安装memecached的时候要先把依赖的软件全部的安装上! 第一步: 在limux编译memcached需要 :yum install gcc make libtool autoconf 着 ...

  8. JSON数据解析及gson.jar包

    从服务器端接收数据的时候,那些数据必须以浏览器能够理解的格式来发送. 服务器端的编程语言只能以如下 3 种格式返回数据: HTML XML JSON JSON一种简单的数据格式,比xml更轻巧. JS ...

  9. OJ随笔——【1088-N!】——同余定理

    题目如下: Description 请求N!(N<=10000),输出结果对10007取余输入每行一个整数n,遇到-1结束.输出每行一个整数,为对应n的运算结果.   Sample Input ...

  10. Android Studio怎样选择查看指定进程的log?

    今天说一个简单的东东,关于Android Studio在logcat中怎样查看指定进程的log. 关于过滤你自己所开发的应用的log.在这篇文章中:Android Studio怎样给log加入过滤项( ...