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录屏的方法就变得简单了.下面就介绍一下具体 ...
随机推荐
- 【niubi-job——一个分布式的任务调度框架】----FAQ文档
引言 本文为niubi-job的FAQ文档,该文档会无限更新.如果您在这里没有找到您想要的答案,请把问题提交到这里. FAQ 1.为什么我的所有任务总是运行在同一个节点上,而没有平均分配到所有节点上? ...
- [USACO 3.1.4]rect1(漂浮法/矩形切割)
描述 N个不同的颜色的不透明的长方形(1 <= N <= 1000)被放置在一张横宽为A竖长为B的白纸上. 这些长方形被放置时,保证了它们的边与白纸的边缘平行. 所有的长方形都放置在白纸内 ...
- 每天一个linux命令(54):sftp命令
sftp 是一个交互式文件传输程式.它类似于 ftp, 但它进行加密传输,比FTP有更高的安全性.下边就简单介绍一下如何远程连接主机,进行文件的上传和下载,以及一些相关操作. 举例,如远程主机的 IP ...
- Microsoft Office下载地址
文件名: cn_office_professional_plus_2016_x86_x64_dvd_6969182.iso 语言: Chinese – Simplified 文件大小:2.41 GB ...
- 关于Jquery 操作Cookie 取值错误
使用JQuery操作cookie时 发生取的值不正确的问题: 结果发现cookie有四个不同的属性: 名称,内容,域,路径 $.cookie('the_cookie'); // 读取 cookie $ ...
- WebService 入门程序(一)
第一步:定义webService接口 package com.robert.ws.service; import javax.jws.WebService; @WebService public in ...
- 14.Android之Layout布局学习
Android布局主要有5种,接下来学习总结下. 1) 最常见的线性布局 LinearLayout 线性布局是Android布局中最简单的布局,也是最常用,最实用的布局. android:orient ...
- Sublime text 快捷键总结
下述快捷键都是我写C++代码时发现的,是否适用其他格式(扩展名)的文件尚为未知. Basic Editing Ctrl + A 全选 Ctrl + S 保存 Ctrl + C 复制 Ctrl + V ...
- Redux初探与异步数据流
基本认知 先贴一张redux的基本结构图 原图来自<UNIDIRECTIONAL USER INTERFACE ARCHITECTURES> 在这张图中,我们可以很清晰的看到,view中产 ...
- android 读取sd卡中的图片
一.获取读取SD卡的权限 <!--在SDCard中创建与删除文件权限 --> <uses-permission android:name="android.perm ...