iOS横屏设置的几种方式
1.界面旋转,MainScreen的宽高不变,键盘位置不变
CGFloat duration = [UIApplication sharedApplication].statusBarOrientationAnimationDuration; [UIView beginAnimations:nil context:nil]; [UIView setAnimationDuration:duration]; self.view.transform =CGAffineTransformMakeRotation(M_PI/2); [UIView commitAnimations];
2.界面旋转,MainScreen的宽高改变,键盘位置不变
if ([[UIDevice currentDevice] respondsToSelector:@selector(setOrientation:)]) {
SEL selector = NSSelectorFromString(@"setOrientation:");
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[UIDevice instanceMethodSignatureForSelector:selector]];
[invocation setSelector:selector];
[invocation setTarget:[UIDevice currentDevice]];
int val = UIInterfaceOrientationLandscapeRight;
[invocation setArgument:&val atIndex:];
[invocation invoke];
}
3.界面旋转,MainScreen的宽高改变,键盘位置改变
a.General—>中勾选Lnadscape Left/Lnadscape Right,默认是勾选上了的

b.控制器中实现以下两个方法:
// 支持设备自动旋转
- (BOOL)shouldAutorotate
{
return YES;
} /**
* 设置特殊的界面支持的方向,这里特殊界面只支持Home在右侧的情况
*/
- (UIInterfaceOrientationMask)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscapeRight;
}
PS:如何判断当前是否横屏,一下3个方法都可以
self.interfaceOrientation(iOS 2.0~8.0)
[UIApplication sharedApplication] statusBarOrientation]
[[UIDevice currentDevice] orientation]
iOS横屏设置的几种方式的更多相关文章
- iOS 全局变量设置的几种方式~
在iOS开发过程中关于全局变量的几个方法 1. 在APPDelegate中声明并初始化全局变量.AppDelegate可以在整个应用程序中调用,在其他页面中可以使用代码段获取AppDelegate的全 ...
- iOS 登陆的实现四种方式
iOS 登陆的实现四种方式 一. 网页加载: http://www.cnblogs.com/tekkaman/archive/2013/02/21/2920218.ht ml [iOS登陆的实现] A ...
- IOS文件操作的两种方式:NSFileManager操作和流操作
1.常见的NSFileManager文件方法 -(NSData *)contentsAtPath:path //从一个文件读取数据 -(BOOL)createFileAtPath: path cont ...
- [Android开发学iOS系列] iOS写UI的几种方式
[Android开发学iOS系列] iOS写UI的几种方式 作为一个现代化的平台, iOS的发展也经历了好几个时代. 本文讲讲iOS写UI的几种主要方式和各自的特点. iOS写UI的方式 在iOS中写 ...
- iOS 收起键盘的几种方式
iOS 收起键盘的几种方式 1.一般的view上收起键盘 // 手势 - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{ ...
- iOS拨打电话的三种方式
iOS拨打电话的三种方式 1,这种方法,拨打完电话回不到原来的应用,会停留在通讯录里,而且是直接拨打,不弹出提示 1 2 var string = "tel:" + "1 ...
- 【Xamarin 挖墙脚系列:IOS 开发界面的3种方式】
原文:[Xamarin 挖墙脚系列:IOS 开发界面的3种方式] xcode6进行三种基本的界面布局的方法,分别是手写UI,xib和storyboard.手写UI是最早进行UI界面布局的方法,优点是灵 ...
- /*透明度设置的两种方式,以及hover的用法,fixed,(relative,absolute)这两个一起用*/
<!DOCTYPE html> /*透明度设置的两种方式,以及hover的用法,fixed,(relative,absolute)这两个一起用*/ <html lang=" ...
- session有效期设置的两种方式
/**session有效期设置的两种方式: * 1.代码设置:session.setMaxInactiveInterval(30);//单位:秒.30秒有效期,默认30分钟. * 2.web.xml中 ...
随机推荐
- C#的默认访问权限(转)
1.在namespace中的类.接口默认是internal类型的,也可以显示的定义为public类型,不允许是其他访问类型.2.在一个类里面,属性和方法默认是private的,可以显示的定义为publ ...
- 九度OJ 1057:众数 (基础题)
时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:8431 解决:2819 题目描述: 输入20个数,每个数都在1-10之间,求1-10中的众数(众数就是出现次数最多的数,如果存在一样多次数的 ...
- MaLoc: a practical magnetic fingerprinting approach to indoor localization using smartphones
https://www.indooratlas.com/ MaLoc: a practical magnetic fingerprinting approach to indoor localizat ...
- 关于JavaScript中prototype机制的理解
最近几天一直在研究JavaScript中原型的机制,从开始的似懂非懂,到今天终于有所领悟.不敢说彻底理解,但是起码算知道怎么回事了. 为什么一开始似懂非懂 开始了解一遍原型机制后,感觉知其然但不知其所 ...
- Java for LeetCode 104 Maximum Depth of Binary Tree
Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the long ...
- 获取原生的DOM方式,DIY脚手架,vue-cli的使用
一 . 获取原生的DOM的方式 在js中,我们可以通过id, class 或者标签获取DOM元素,vue中也为我们提供了获取原生DOM的方法,就是给标签或者组件添加 ref 属性,通过 this.$r ...
- linux下安装https证书
https://www.aliyun.com/jiaocheng/165422.html
- git format-patch的使用【转】
本文转载自:http://blog.chinaunix.net/uid-28621021-id-3487102.html git format-patch的使用 1.在dev1分支上,打出所有de ...
- TopCoder SRM420 Div1 RedIsGood —— 期望
题目链接:https://vjudge.net/problem/TopCoder-9915 (论文上的题) 题解: 更正:, i>0, j>0 代码如下: #include <ios ...
- 【LeetCode】两个有序数组合成一个有序数组
a = [1,3,5,7,9]b = [2,4,6,8,10]c= [] while len(a) > 0: if len(b) == 0: c.extend(a) break min_num ...