竖屏情况下: [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];
}

最新文章

  1. javascript 练习示例(一)
  2. Zip加密
  3. nodejs笔记
  4. Cell右滑的动作状态
  5. SpringMvc异常处理
  6. 【BZOJ】【1023】【SHOI2008】cactus仙人掌图
  7. Matlab GUI界面
  8. Bzoj 1756: Vijos1083 小白逛公园 线段树
  9. codeforces567E. President and Roads
  10. struts2的注解配置全面解析
  11. Unity3D使用mesh创建一个正方形
  12. achartengine画出动态折线图
  13. iOS平台软件开发工具(一)-新建的工程使用CocoaPods工具集成第三方框架
  14. strcat函数
  15. C++对象模型的那些事儿之一:对象模型(上)
  16. 我的 FPGA 学习历程(01)—— FPGA 基础知识和 Quartus 的安装
  17. 微服务与Spring Cloud资料
  18. tomcat启动报错:Annotation-specified bean name 'patrolTrailServiceImpl' for bean class [cn.oppo.inventoryService.patrolTrailServiceImpl] con
  19. 从零搭建 ES 搜索服务(五)搜索结果高亮
  20. sas data infile 语句选项

热门文章

  1. Android开发的那些坑和小技巧
  2. Javascript基础系列之(四)数据类型 (数组 array)
  3. JSON.NET 简单的使用
  4. Docker-2 的创建、启动、终止、删除、迁移等
  5. 【转】高斯消元模板 by kuangbin
  6. 【HDU 1228】A + B
  7. MySQL安装最后一步apply security settings错误
  8. (Beta)Let's-Beta阶段展示博客
  9. TYVJ1305 最大子序和
  10. The Longest Increasing Subsequence (LIS)