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

#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. GraphicsMagick的命令行使用示例

    GraphicsMagick是从 ImageMagick 5.5.2 分支出来的,但是现在他变得更稳定和优秀,GM更小更容易安装.GM更有效率.GM的手册非常丰富GraphicsMagick的命令与I ...

  2. bootstrap栅格布局学习历程

    了解一个东西.他叫什么?他由什么组成,能做什么? 现在响应式的网站(在不同分辨率下有不同的布局)很瘦欢迎.优点:1.解决设备之间的差异化展示缺点:a.兼容性代码多,工作量大,加载速度受到影响;b.用户 ...

  3. Java URL类踩坑指南

    背景介绍 最近再做一个RSS阅读工具给自己用,其中一个环节是从服务器端获取一个包含了RSS源列表的json文件,再根据这个json文件下载.解析RSS内容.核心代码如下: class Presente ...

  4. CCF认证之——相反数

    这道题目非常简单! #include<iostream> using namespace std; int main() { ],n,count=; cin >> n; ; i ...

  5. Smarty基础用法

    一.Smarty基础用法: 1.基础用法如下 include './smarty/Smarty.class.php';//引入smarty类 $smarty = new Smarty();//实例化s ...

  6. Unity3d的模型自动导入帧数表

    开发中经常需要,对美术模型进行一些处理.(以fbx为例) 例如,需要把动作的名字.start和end加入animations的clips. 如果手动操作,就是在模型的Inspector窗口,一个动作点 ...

  7. 如何利用panel在一个窗口中实现诸多页面的显示

    Book_register form11 = new Book_register();//new一个对象 form11.TopLevel = false;//去除子窗体的顶级窗体设置 form11.P ...

  8. 使用fastdfs-zyc监控FastDFS文件系统

    1.安装jdk运行环境 jdk下载地址:http://www.oracle.com/technetwork/java/javase/downloads/index.html 此处我使用的jdk7U99 ...

  9. this的取值

    在函数中this到底取何值,是在函数真正被调用执行的时候确定的,函数定义的时候确定不了. 情况1:构造函数 function Foo(){ this.name="王福朋" this ...

  10. OBS源码解析(2)run_program函数

    static int run_program(fstream &logFile, int argc, char *argv[]){ /*初始化和读取profile相关信息*/ int ret ...