这几天做App的时候,需要添加旋转屏通知以便调整UI布局

刚开始我使用的是UIDeviceOrientationDidChangeNotification,

一直有一些问题就是,如果使用这个通知,当iPhone/iPad旋转的时候,你会得到的旋转方向会是所有的

  1. UIDeviceOrientationUnknown和UIDeviceOrientationFaceUp等
  1. typedef enum {
  2. UIDeviceOrientationUnknown,
  3. UIDeviceOrientationPortrait,            // Device oriented vertically, home button on the bottom
  4. UIDeviceOrientationPortraitUpsideDown,  // Device oriented vertically, home button on the top
  5. UIDeviceOrientationLandscapeLeft,       // Device oriented horizontally, home button on the right
  6. UIDeviceOrientationLandscapeRight,      // Device oriented horizontally, home button on the left
  7. UIDeviceOrientationFaceUp,              // Device oriented flat, face up
  8. UIDeviceOrientationFaceDown             // Device oriented flat, face down
  9. } UIDeviceOrientation;

但是我不需要对

  1. UIDeviceOrientationUnknown和UIDeviceOrientationFaceUp

进行处理,所以有时候就会出错,

后来更改为通知UIApplicationDidChangeStatusBarFrameNotification

在只有status更改位置的时候你才会收到通知,即你此时得到的方向只会是

    1. UIDeviceOrientationPortrait
    2. UIDeviceOrientationPortraitUpsideDown
    3. UIDeviceOrientationLandscapeLeft
    4. UIDeviceOrientationLandscapeRight

UIDeviceOrientationDidChangeNotification和UIApplicationDidChangeStatusBarFrameNotification的更多相关文章

  1. 关于监听与控制设备旋转全解析(UIDeviceOrientationDidChangeNotification)

    一类情况: 初始化app的方向,比如只支持横屏或者竖屏.下面举例只支持竖屏的案例 在app的属性里面手动设置 上面标注了该app支持的方向种类,要是在app里支持Portrait方向,还需要添加以下代 ...

  2. iOS 系统消息

    转载自:http://momirror.blog.163.com/blog/static/48418184201361541235481/ 一.键盘 1.UIKeyboardWillShowNotif ...

  3. iOS系统消息

    一.键盘1.UIKeyboardWillShowNotification-将要弹出键盘2.UIKeyboardDidShowNotification-显示键盘3.UIKeyboardWillHideN ...

  4. iOS各种系统通知Name

    当了一次搬运工,原地址:http://blog.csdn.net/db905517804/article/details/50569949 用法: - (void) viewWillAppear:(B ...

  5. iOS 工程默认只允许竖屏,在单独界面进行横竖转换,屏幕旋转

    只含有 .关于横竖屏的代码 #import "InspectionReportViewController.h" #define SCREEN_WIDTH ([UIScreen m ...

  6. ios单独的页面支持横竖屏的状态调整,HTML5加载下(更新2)

    单独的页面支持横竖屏的状态调整,HTML5加载下 工程中设置只支持竖屏状态,在加载HTML5的界面可以是横竖屏的,在不对工程其他界面/设置做调整的同时,可以这样去 #import "View ...

  7. iOS系统NSNotificationCenter中的常用通知名称

    //音频 AVF_EXPORT NSString *const AVAudioSessionInterruptionNotification //音频中断出现 AVF_EXPORT NSString ...

  8. iOS 系统消息通知

    一.键盘 1.UIKeyboardWillShowNotification-将要弹出键盘 2.UIKeyboardDidShowNotification-显示键盘 3.UIKeyboardWillHi ...

  9. iOS通知中心

    iOS通知中心 它是iOS程序内部的一种消息广播机制,通过它,可以实现无引用关系的对象之间的通信.通知中心他是基于观察者模式,它只能进行程序内部通信,不能跨应用程序进程通信. 当通知中心接受到消息后会 ...

随机推荐

  1. Appium Android Bootstrap源代码分析之启动执行

    通过前面的两篇文章<Appium Android Bootstrap源代码分析之控件AndroidElement>和<Appium Android Bootstrap源代码分析之命令 ...

  2. 自己写unicode转换ascii码,wchar*到char*

    对于ascii码的char事实上就是unicode码wchar的首个字节码, 如wchar[20] = "qqqq"; 在内存中排码事实上是char的'q' '\0'这类.因此我们 ...

  3. HDU1788 Chinese remainder theorem again【中国剩余定理】

    题目链接: pid=1788">http://acm.hdu.edu.cn/showproblem.php?pid=1788 题目大意: 题眼下边的描写叙述是多余的... 一个正整N除 ...

  4. Android上玩玩Hook?

    在中国互联网这片弱肉强食的丛林中.封闭抄袭是垄断巨头的通行证.创新是弱小创业者的墓志铭. 了解Hook 还没有接触过Hook技术读者一定会对Hook一词感觉到特别的陌生.Hook英文翻译过来就是&qu ...

  5. 【LeetCode-面试算法经典-Java实现】【121-Best Time to Buy and Sell Stock(最佳买卖股票的时间)】

    [121-Best Time to Buy and Sell Stock(最佳买卖股票的时间)] [LeetCode-面试算法经典-Java实现][全部题目文件夹索引] 原题 Say you have ...

  6. jquery10 闭包示例

    o = { a:1, o:{ b:2, f : function(){ alert(o.a); alert(o.b);//undefined } } } o.o.f(); o = { a:7, o : ...

  7. python-安装xlrd xlwt 插件

    最近需要对比两个表格的内容,然后修改其中的某列内容.因为工作量太大,所以想通过python来实现.上网查了相关的操作,其中牵扯到两个功能模块,xlrd xlwt.这两个功能模块分别是对excel进行读 ...

  8. Elasticsearch之shield(权限)插件安装之后的浏览详解

    前期博客 Elasticsearch-2.4.3的3节点安装(多种方式图文详解)(含 head.kopf.marvel.shield和watcher插件安装和使用) 访问es:-u es_admin ...

  9. centos6.5 数据库的安装

    mongo https://www.cnblogs.com/layezi/p/7290082.html

  10. gSOAP 使用WebServer心得

    关于正常怎么使用gSOAP的话,下面那篇博客已经讲得非常详细,我就不再赘述了 https://www.cnblogs.com/dengpeng1004/p/6165751.html 问题1: WCF ...