UIDeviceOrientation      是机器硬件的当前旋转方向   这个你只能取值 不能设置

UIInterfaceOrientation   是你程序界面的当前旋转方向   这个可以设置

//判断设备现在的方向:

//C代码  收藏代码

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation

{

//宣告一個UIDevice指標,並取得目前Device的狀況

UIDevice *device = [UIDevice currentDevice] ;

//取得當前Device的方向,來當作判斷敘述。(Device的方向型態為Integer)

switch (device.orientation) {

case UIDeviceOrientationFaceUp:

NSLog(@"螢幕朝上平躺");

break;

case UIDeviceOrientationFaceDown:

NSLog(@"螢幕朝下平躺");

break;

//系統無法判斷目前Device的方向,有可能是斜置

case UIDeviceOrientationUnknown:

NSLog(@"未知方向");

break;

case UIDeviceOrientationLandscapeLeft:

NSLog(@"螢幕向左橫置");

break;

case UIDeviceOrientationLandscapeRight:

NSLog(@"螢幕向右橫置");

break;

case UIDeviceOrientationPortrait:

NSLog(@"螢幕直立");

break;

case UIDeviceOrientationPortraitUpsideDown:

NSLog(@"螢幕直立,上下顛倒");

break;

default:

NSLog(@"無法辨識");

break;

}

// Return YES for supported orientations

return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft); // 只支持向左横向, YES 表示支持所有方向

}

//或者

//C代码  收藏代码

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation

{

UIDeviceOrientation deviceOrientation = [UIDevice currentDevice].orientation;

if (UIDeviceOrientationIsLandscape(deviceOrientation)) NSLog(@"横向");

else if(UIDeviceOrientationIsPortrait(deviceOrientation)) NSLog(@"纵向");

// // Return YES for supported orientations

return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft); // 只支持向左横向, YES 表示支持所有方向

}

//Portrait 表示 纵向,Landscape 表示 横向。

//C代码  收藏代码

typedef enum {

UIDeviceOrientationUnknown,

UIDeviceOrientationPortrait,            // Device oriented vertically, home button on the bottom

UIDeviceOrientationPortraitUpsideDown,  // Device oriented vertically, home button on the top

UIDeviceOrientationLandscapeLeft,       // Device oriented horizontally, home button on the right

UIDeviceOrientationLandscapeRight,      // Device oriented horizontally, home button on the left

UIDeviceOrientationFaceUp,              // Device oriented flat, face up

UIDeviceOrientationFaceDown             // Device oriented flat, face down

} UIDeviceOrientation;

//C代码  收藏代码

typedef enum {

UIInterfaceOrientationPortrait           = UIDeviceOrientationPortrait,

UIInterfaceOrientationPortraitUpsideDown = UIDeviceOrientationPortraitUpsideDown,

UIInterfaceOrientationLandscapeLeft      = UIDeviceOrientationLandscapeRight,

UIInterfaceOrientationLandscapeRight     = UIDeviceOrientationLandscapeLeft

} UIInterfaceOrientation;

//C代码  收藏代码

#define UIDeviceOrientationIsPortrait(orientation)  ((orientation) == UIDeviceOrientationPortrait || (orientation) == UIDeviceOrientationPortraitUpsideDown)

#define UIDeviceOrientationIsLandscape(orientation) ((orientation) == UIDeviceOrientationLandscapeLeft || (orientation) == UIDeviceOrientationLandscapeRight)

//上面是重要的源代码,已经解释的非常清楚。UIDeviceOrientationIsPortrait(orientation) 跟  ((orientation) == UIDeviceOrientationPortrait || (orientation) == UIDeviceOrientationPortraitUpsideDown) 完全是一个意思。

UIDeviceOrientation UIInterfaceOrientation 区别的更多相关文章

  1. UIDeviceOrientation 和 UIInterfaceOrientation

    有时候,我们处理自动布局时,需要获取到屏幕旋转方向: 以下为本人亲测: UIInterfaceOrientation: 我们需要在- (void)viewDidLoad或其他方法中添加观察者,检测屏幕 ...

  2. bundle与package区别与联系

    转:http://blog.csdn.net/lmbda/article/details/17895619 bundle是Apple提供的软件安装的便捷方法. bundle为用户和开发者提供了一个简单 ...

  3. 关于UIInterfaceOrientation的一个bug

    在ios中获取设备当前方向的枚举有UIInterfaceOrientation和UIDeviceOrientation ,前者包含枚举 Unknown//未知 Portrait//屏幕竖直,home键 ...

  4. 3.20 内存及效率的一些总结 3.21 设置竖屏 3.22 CCLOG与CCLog区别

    3.20 内存及效率的一些总结 3.21 设置竖屏 1.android AndroidManifest.xml文件中, screenOrientation="landscape" ...

  5. c#与java的区别

    经常有人问这种问题,用了些时间java之后,发现这俩玩意除了一小部分壳子长的还有能稍微凑合上,基本上没什么相似之处,可以说也就是马甲层面上的相似吧,还是比较短的马甲... 一般C#多用于业务系统的开发 ...

  6. jquery和Js的区别和基础操作

    jqery的语法和js的语法一样,算是把js升级了一下,这两种语法可以一起使用,只不过是用jqery更加方便 一个页面想要使用jqery的话,先要引入一下jqery包,jqery包从网上下一个就可以, ...

  7. 【原】nodejs全局安装和本地安装的区别

    来微信支付有2年多了,从2年前的互联网模式转变为O2O模式,主要的场景是跟线下的商户去打交道,不像以往的互联网模式,有产品经理提需求,我们帮忙去解决问题. 转型后是这样的,团队成员更多需要去寻找业务的 ...

  8. 探究@property申明对象属性时copy与strong的区别

    一.问题来源 一直没有搞清楚NSString.NSArray.NSDictionary--属性描述关键字copy和strong的区别,看别人的项目中属性定义有的用copy,有的用strong.自己在开 ...

  9. X86和X86_64和X64有什么区别?

    x86是指intel的开发的一种32位指令集,从386开始时代开始的,一直沿用至今,是一种cisc指令集,所有intel早期的cpu,amd早期的cpu都支持这种指令集,ntel官方文档里面称为&qu ...

随机推荐

  1. hdu5338 ZZX and Permutations(贪心、线段树)

    转载请注明出处: http://www.cnblogs.com/fraud/          ——by fraud ZZX and Permutations Time Limit: 6000/300 ...

  2. shell中的case表达式

    语法格式 case var in pattern1 | patter2) command1 command2;; pattern3) command1 command2;; *) default co ...

  3. hprof教程

    大部分内容参考http://www.linuxidc.com/Linux/2012-04/58178.htm J2SE中提供了一个简单的命令行工具来对java程序的cpu和heap进行 profili ...

  4. WordPress插件制作教程(六): 插件函数之动作(Actions)函数

    这一篇为大家说一下WordPress插件函数吧,要制作插件,了解这些函数是非常有必要的 WordPress插件函数分为“动作”(Actions)和过滤器”(Filters),WordPress 使用这 ...

  5. ASP转PHP手记

    打算将动易网站管理系统移植到PHP环境中,寻寻觅觅了很多PHP内容管理网站,发现网上有动易转PHPCMS的代码,所以就拿定注意用PHPCMS的在google上找到一转换程序,动手做来还成功了,现将此次 ...

  6. 字符串:各种奇葩的内置方法 - 零基础入门学习Python014

    字符串:各种奇葩的内置方法 让编程改变世界 Change the world by program 字符串:各种奇葩的内置方法 或许现在又回过头来谈字符串,有些朋友可能会觉得没必要,也有些朋友会觉得不 ...

  7. 转载收藏之用 - 微信公众平台开发教程(四):Hello World

    这一篇文章其实可以写在很前面,不过我还是希望开发者们尽多地了解清楚原理之后再下手. 通过上一篇Senparc.Weixin.MP SDK 微信公众平台开发教程(三):微信公众平台开发验证,我们已经使微 ...

  8. Effective Java2读书笔记-类和接口(二)

    第15条:使可变性最小化 通过一个复数类来看不可变类. public final class Complex { private final double re; private final doub ...

  9. 暴力破解UltraEdit v21 无需注册

    一.复制一份UltraEdit安装目录中的主程序uedit32.exe,到任意目录,用UltraEdit打开复制的uedit32.exe文件. 二.修改以下内容 原来:00094750h: BE DC ...

  10. unix c 11

    多线程(thread)    操作系统支持多进程,进程内部使用多线程.    进程是 重量级的,拥有自己 独立的内存空间.    线程是 轻量级的,不需要拥有自己 独立的内存空间,线程的内存空间:1 ...