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录屏的方法就变得简单了.下面就介绍一下具体 ...
随机推荐
- Unity Networking API文档翻译(二):The High Level API
高级API (HLAPI) 是用来提供给Unity 创建多人在线游戏的组件.它是在底层传输层的基础上构建的, 对多人在线游戏提供了很多通用的功能.当传输层支持各种网络拓扑结构的时候,HLAPI是一个功 ...
- DOM系列---DOM操作表格
DOM在操作生成HTML上,还是比较简明的.不过,由于浏览器总是存在兼容和陷阱,导致最终的操作就不是那么简单方便了.本篇章主要了解一下DOM操作表格. 一.操作表格 <table>标签是H ...
- AngularJS开发指南3:Angular主要组成部分以及如何协同工作
AngularJS的主要组成部分是: 启动(startup) - 展示“hello world!” 执行期(runtime) - AngularJS 执行期概览 作用域(scope) - 视图和控制器 ...
- 积木(DP)问题
问题:Do you remember our children time? When we are children, we are interesting in almost everything ...
- 写在SDOI2016Round1前的To Do List
理性的整理了一下自己的不足. 计算几何啥都不会,字符串类DP毫无练习,数据结构写的不熟,数论推不出式子,网络流建模常建残: 需要达成的任务: 一.网络流: 熟练网络流的板子(之前一直仰慕zkw费用流, ...
- 洛谷P2279 [HNOI2003]消防局的设立
题目描述 2020年,人类在火星上建立了一个庞大的基地群,总共有n个基地.起初为了节约材料,人类只修建了n-1条道路来连接这些基地,并且每两个基地都能够通过道路到达,所以所有的基地形成了一个巨大的树状 ...
- 分享一段Java搞笑的代码注释
今天在群里看到有人分享了一段搞笑的注释代码,觉得挺好玩的,在这里收藏一下 // _ooOoo_ // o8888888o // 88" . "88 // (| -_- |) // ...
- js中日历的代码
Html <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3 ...
- 初识A*算法
写这篇文章的初衷是应一个网友的要求,当然我也发现现在有关人工智能的中文站点实在太少,我在这里抛砖引玉,希望大家都来热心的参与. 还是说正题,我先拿A*算法开刀,是因为A*在游戏中有它很典型的用法,是人 ...
- tomcat架构
很多开源应用服务器都是集成tomcat作为web container的,而且对于tomcat的servlet container这部分代码很少改动.这样,这些应用服务器的性能基本上就取决于Tomcat ...