iOS 工程默认只允许竖屏,在单独界面进行横竖转换,屏幕旋转
只含有 。关于横竖屏的代码
#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 工程默认只允许竖屏,在单独界面进行横竖转换,屏幕旋转的更多相关文章
- iOS的横屏(Landscape)与竖屏(Portrait)InterfaceOrientation
http://www.molotang.com/articles/1530.html 接着上篇写的触摸事件,这次借机会整理下iOS横屏和竖屏的翻转方向支持,即InterfaceOrientation相 ...
- iOS强制横屏或强制竖屏
原文链接 https://www.jianshu.com/p/d6cb54d2eaa1 亲测第二种我这边是阔以滴 第一种解决方案(不推荐,直接跳过看第二种解决方案): //强制转屏 - (void)i ...
- Android和iOS中Cocos2dx的横屏竖屏设置
一.横屏.竖屏设置 1.android AndroidManifest.xml文件中, screenOrientation="landscape" 为横屏, screenOrien ...
- iOS强制切换横屏、竖屏
切换横竖屏最直接的方式是调用device的setOrientation方法.但是从sdk3.0以后,这个方法转为似有API,如果要上AppStore的话,要慎用! if ([[UIDevice cur ...
- iOS设置竖屏,播放视频可以任性旋转的解决方法,亲测可用
之前在网上找了很多方法,都是强制横屏,但是如果设备关闭旋转锁定,强制横屏后把设备竖立起来,播放器也会跟着竖过来,但是就回不去了.现在项目要求让app默认都是竖屏,只有在全屏播放的时候可以自由旋转,于是 ...
- iOS 全局竖屏 单个viewcontroller点击按钮支持横屏
问题描述:项目工程只支持竖屏,在播放器页面需要点击按钮进行横竖屏切换,并能根据手机的方向进行自动旋转 如图:只勾选了竖屏 解决方法:(主要是采用视图transform的原理 横屏时调整视频视图上的每个 ...
- 转载:Android横屏竖屏切换的问题
一.禁止横竖屏转换 Android横竖屏切换在手机开发中比较常见,很多软件在开发过程中为了避免横竖屏切换时引发不必要的麻烦,通常禁止掉横竖屏的切换, 通过在AndroidManifest.xml中设置 ...
- Android4.0强制横屏竖屏
Android的启动默认是横屏或者竖屏我们的TV本来是横屏显示,但是有客户竟然要竖屏显示,昨天快下班收到的需求,竟然说7.19就要搞定.思路有2个,一个就是修改LCD的默认输出,但是这个不是我这个水平 ...
- 关于Cocos2d-x手机上运行游戏的时候屏幕横屏改竖屏的解决方案
cocos2d-x打包的时候默认是横屏,如果要改成竖屏,步骤如下: 1.打开项目 2.打开proj.android 3.编辑AndroidManifest.xml 4. 找到这一句android:sc ...
随机推荐
- Postman+newman+jenkins构建
最近忙着项目接口测试,经过不同工具的对比,发现postman使用起来挺顺手的,所以马上决定使用这个工具进行接口测试工作.刚开始的时候,了解了下接口测试的相关信息,直接着手编写接口测试的测试用例信息 ...
- tensorflow 学习笔记(转)
转自:http://blog.csdn.net/qq_32166627/article/details/52734387 侵删. tensorflow中有一类在tensor的某一维度上求值的函数.如: ...
- PHP+Redis 实例【一】点赞 + 热度 下篇
这篇主要讲如何将数据保存回Mysql,但是里面还会涉及到如何将错误信息以及提示信息保存到文件里,方便以后的运维,再有就是如何使用PHP写进程BAT. Redis数据刷回数据库前的知识准备 首先针对上篇 ...
- GIT常用命令(图片版)
Git 是一个很强大的分布式版本控制系统.它不但适用于管理大型开源软件的源代码,管理私人的文档和源代码也有很多优势. 本来想着只把最有用.最常用的 Git 命令记下来,但是总觉得这个也挺有用.那个也用 ...
- 通过YUM升级centOS内核,以便安装docker
安装Docker要满足一定的条件,对于cents系统,要求必须是64位,并且内核版本是3.10以上. 如果你的centos操作系统内核低于3.10,需要升级到这个版本以上,才能安装docker. 第一 ...
- esp8266 SDK开发之编译流程
最近刚完成自己8266的小项目,已经发布在github上,有兴趣的朋友可以看一下 github地址:esp-ujn 1. 通过MQTT协议与服务器交互 2. 内置HTTP服务器,支持通过浏览器进行参数 ...
- Eureka学习例子
Eureka学习 Spring Cloud下有很多工程: Spring Cloud Config:依靠git仓库实现的中心化配置管理.配置资源可以映射到Spring的不同开发环境中,但是也可以使用在非 ...
- 》》webpack打包成的文件
/******/(function(modules) { // webpackBootstrap /******/ // The module cache /******/ var installed ...
- SDUTOJ 贪心 -商人小鑫
题目描写叙述 小鑫是个商人,当然商人最希望的就是多赚钱.小鑫也一样. 这天,他来到了一个遥远的国度.那里有着n件商品,对于第i件商品须要付出ci的价钱才干得到. 当然.对于第i件商品,小鑫在自己心中有 ...
- Unity打包android的apk与数据包.obb分离和apk签名
那么,通过以上图片.我相信大多数人已经知道怎么创建了,apk签名比較简单,假设之前没有签名文件.那么选择图中的Create New Keystore然后在以下两个password框中输入passwor ...