Iphone和iPad适配, 横竖屏
竖屏情况下: [UIScreen mainScreen].bounds.size.width = 320
[UIScreen mainScreen].bounds.size.width = 568
横屏情况下:
[UIScreen mainScreen].bounds.size.width = 568
[UIScreen mainScreen].bounds.size.height = 320
UIViewController 和 UIWindow同理
1. storyboard iphone和 iPad版
即为iphone和ipad分别创建xib/storyboard文件
Main_iPhone.storyboard
Main_iPad.storyboard
横竖屏
苹果官方文档:
When the user changes the device orientation, the system calls this method on the root view controller or the topmost presented view controller that fills the window. If the view controller supports the new orientation, the window and view controller are rotated to the new orientation. This method is only called if the view controller's shouldAutorotate method returns YES.
- (BOOL)shouldAutorotate
{
return YES;
}
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskAll;
}
注意要写在最顶层视图控制器, (self.window.rootViewController) , 否则不会进入以上方法
而且
supportedInterfaceOrientations的返回值必须是
UIInterfaceOrientationMaskLandscapeLeft 或者 UIInterfaceOrientationMaskLandscapeRight 或者...
总之必须加Mask
通知是当前线程异步
tabbarcontroller 为 根控制器的情况
- (BOOL)shouldAutorotate
{
return [self.selectedViewController shouldAutorotate];
} - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return [self.selectedViewController preferredInterfaceOrientationForPresentation];
} - (NSUInteger)supportedInterfaceOrientations
{
return [self.selectedViewController supportedInterfaceOrientations];
}
navigationcontroller为根控制器的情况:
- (BOOL)shouldAutorotate
{
return [self.viewControllers.lastObject shouldAutorotate];
} - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return [self.viewControllers.lastObject preferredInterfaceOrientationForPresentation];
} - (NSUInteger)supportedInterfaceOrientations
{
return [self.viewControllers.lastObject supportedInterfaceOrientations];
}
Iphone和iPad适配, 横竖屏的更多相关文章
- ios tableview 适配横竖屏
tableview.autoresizingMask=UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;
- 仿iPhone、iPad界面滑屏切换
<!DOCTYPE html> <html lange='en'> <head> <meta charset='UTF-8'> <title> ...
- JS禁止横竖屏切换,强制横竖屏显示
js判断屏幕横竖屏: function orient() { //alert('gete'); if (window.orientation == 0 || window.orientation == ...
- iPad横竖屏代码适配
你可能非常了解用不同的方式去适配不同尺寸的iPhone屏幕,在适配iPhone屏幕时你需要考虑的只是屏幕大小变化带来的UI元素间隔的变化,但是在iPad上主要针对的是横竖屏下完全不同的UI元素的布局, ...
- 48 (OC)* 适配iPad和iPhone、以及横竖屏适配。
一:核心方法 1.三个方法 1.1:开始就会触发 - (void)viewWillLayoutSubviews; 1.2:开始就会触发 - (void)viewDidLayoutSubviews; 1 ...
- ios5和ios6横竖屏支持及ipad和iphone设备的判断
ios5和ios6横竖屏支持及ipad和iphone设备的判断 判断是ipad还是iphone设备.此定义在PayViewControllerDemo-Prefix.pch 定义如下: #define ...
- (一〇八)iPad开发之横竖屏适配
在iPad开发中,横竖屏的视图常常是不同的,例如侧边栏Dock,在横屏时用于屏幕较宽,可以展示足够多的内容,每个按钮都可以展示出标题:而竖屏时Dock应该比较窄,只显示图标不现实按钮标题. iPad比 ...
- iOS 横竖屏适配
关于横竖屏适配 也没做过,今天读别人的源码,遇到了.为了了解清楚,就系统的学习一下. 一 横竖屏方向枚举 关于横竖屏一共有三种枚举 UIInterfaceOrientation UIInterface ...
- 在Mac电脑上为iPhone或iPad录屏的方法
在以前的Mac和iOS版本下,录制iPhone或者iPad屏幕操作是一件稍微复杂的事情.但是随着Yosemite的出现,在Mac电脑上为iPhone或iPad录屏的方法就变得简单了.下面就介绍一下具体 ...
随机推荐
- AutoMapper用法(转载)
申明 本文转载自http://www.qeefee.com/article/automapper 作者:齐飞 配置AutoMapper映射规则 AutoMapper是基于约定的,因此在实用映射之前,我 ...
- Zebra_Dialog 弹出层插件
. Default dialog box, no custom settings. Click here to open. $.Zebra_Dialog('<strong>Zebra_Di ...
- (好文推荐)一篇文章看懂JavaScript作用域链
闭包和作用域链是JavaScript中比较重要的概念,首先,看看几段简单的代码. 代码1: var name = "stephenchan"; var age = 23; func ...
- 第八章:Javascript函数
函数是这样一段代码,它只定义一次,但可能被执行或调用任意次.你可能从诸如子例程(subroutine)或者过程(procedure)这些名字里对函数概念有所了解. javascript函数是参数化的: ...
- AngularJS开发指南15:AngularJS的创建服务,将服务注入到控制器,管理服务依赖详解
创建服务 虽然AngularJS提供了很多有用的服务,但是如果你要创建一个很棒的应用,你可能还是要写自己的服务.你可以通过在模块中注册一个服务工厂函数,或者通过Module#factory api或者 ...
- javascript去掉字符串前后空格
使用场景 当我们进行一些页面编辑时,字符串前后的空格,通常是无效的.因此需要在获取信息时,进行过滤. 比如: 输入:[空格][空格]a[空格]b[空格][空格][空格] 得到:a[空格]b 代码如下: ...
- NABCD分析java音乐播放器
程设计题目:java音乐播放器 一.课程设计目的 1.编程设计音乐播放软件,使之实现音乐播放的功能. 2.培养学生用程序解决实际问题的能力和兴趣. 3.加深java中对多媒体编程的应用. 二.课程设计 ...
- java_WEB开发 防刷新
客户端处理: 面对客户端我们可以使用Javascript脚本来解决,如下 1.重复刷新.重复提交 Ways One:设置一个变量,只允许提交一次. <script language=" ...
- if转换switch的小技巧
class Program { static void Main(string[] args) { /* 对学员的结业考试成绩评测(用switch) * 成绩>=90……A * 90>成绩 ...
- maven_创建quickstart模板时异常
错误信息: Could not resolve archetype org.apache.maven.archetypes:maven-archetype-quickstart:1.1 from an ...