UIDeviceOrientation 和&nbsp…
来源:互联网 发布:数控车t型螺纹编程实例 编辑:程序博客网 时间:2024/05/18 03:18
UIDeviceOrientation
UIInterfaceOrientation
判断设备现在的方向:
- -
( BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation - {
-
//宣告一個UIDevice指標,並取得目前Device的狀況 -
UIDevice *device = [UIDevice currentDevice] ; -
-
//取得當前Device的方向,來當作判斷敘述。(Device的方向型態為Integer) -
switch (device.orientation) { -
case UIDeviceOrientationFaceU p: -
NSLog(@"螢幕朝上平躺"); -
break; -
-
case UIDeviceOrientationFaceD own: -
NSLog(@"螢幕朝下平躺"); -
break; -
-
//系統無法判斷目前Device的方向,有可能是斜置 -
case UIDeviceOrientationUnkno wn: -
NSLog(@"未知方向"); -
break; -
-
case UIDeviceOrientationLands capeLeft: -
NSLog(@"螢幕向左橫置"); -
break; -
-
case UIDeviceOrientationLands capeRight: -
NSLog(@"螢幕向右橫置"); -
break; -
-
case UIDeviceOrientationPortr ait: -
NSLog(@"螢幕直立"); -
break; -
-
case UIDeviceOrientationPortr aitUpsideDown: -
NSLog(@"螢幕直立,上下顛倒"); -
break; -
-
default: -
NSLog(@"無法辨識"); -
break; -
} -
-
// Return YES for supported orientations -
return (interfaceOrientation //== UIInterfaceOrientationLa ndscapeLeft); 只支持向左横向, YES 表示支持所有方向 - }
或者
- -
( BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation - {
-
UIDeviceOrientation deviceOrientation = [UIDevice currentDevice].orientation; -
if (UIDeviceOrientationIsLan "横向");dscape(deviceOrientation)) NSLog(@ -
else if(UIDeviceOrientationIsPor trait(deviceOrientation)) "纵向");NSLog(@ -
-
// // Return YES for supported orientations -
return (interfaceOrientation //== UIInterfaceOrientationLa ndscapeLeft); 只支持向左横向, YES 表示支持所有方向 - }
Portrait 表示 纵向,Landscape 表示横向。
- typedef
enum { -
UIDeviceOrientationUnkno wn, -
UIDeviceOrientationPortr ait, // Device oriented vertically, home button on the bottom -
UIDeviceOrientationPortr aitUpsideDown, // Device oriented vertically, home button on the top -
UIDeviceOrientationLands capeLeft, // Device oriented horizontally, home button on the right -
UIDeviceOrientationLands capeRight, // Device oriented horizontally, home button on the left -
UIDeviceOrientationFaceU p, // Device oriented flat, face up -
UIDeviceOrientationFaceD own // Device oriented flat, face down - }
UIDeviceOrientation;
- typedef
enum { -
UIInterfaceOrientationPo rtrait = UIDeviceOrientationPortr ait, -
UIInterfaceOrientationPo rtraitUpsideDown = UIDeviceOrientationPortr aitUpsideDown, -
UIInterfaceOrientationLa ndscapeLeft = UIDeviceOrientationLands capeRight, -
UIInterfaceOrientationLa ndscapeRight = UIDeviceOrientationLands capeLeft - }
UIInterfaceOrientation;
- #define
UIDeviceOrientationIsPor trait(orientation) ((orientation) == UIDeviceOrientationPortr ait || (orientation) == UIDeviceOrientationPortr aitUpsideDown) - #define
UIDeviceOrientationIsLan dscape(orientation) ((orientation) == UIDeviceOrientationLands capeLeft || (orientation) == UIDeviceOrientationLands capeRight)
上面是重要的源代码,已经解释的非常清楚。UIDeviceOrientationIsPor
本文转自:justcoding.iteye.com/blog/1472932
0 0
- UIDeviceOrientation 和&nbsp…
- iOS UIDeviceOrientation&nbs…
- 转:为何 Emacs 和&nbsp…
- b MAIN 和 ldr&nbs…
- b MAIN 和 ldr&nbs…
- 弹出层总结 和 &n…
- weibo 登录&nbsp…
- Android edittext&nbsp…
- !!! FAILED BINDER&nbsp…
- OGNL & ValueStack&…
- sql中的group by 和&nbs…
- iPhone loadView 和&nbs…
- oracle中的exists 和not&nbsp…
- Android TabHost 和&nbs…
- Javascript_DOMContentLoaded&nbsp…
- ApplicationEventMulticaster&nbsp…
- LA 5713 Qin&nbsp…
- Convex Hull Algorithms & general…
- iOS 开发 网络实时监测
- Retrofit学习(一)
- IOS atomic与nonatomic,assi…
- 远程访问ipython
- ARC的具体操作机制
- UIDeviceOrientation 和&nbsp…
- iOS6的旋屏控制技巧
- UILable字符串的不同字段的样式设…
- iOS数据持久化的四种方法
- iOS+的多核编程和内存管理
- android7.0 popupwindow在所点击的控件下方显示,会掩盖本身的控件,所以可以将高多加控件的本身高度
- Store Kit Guide
- ios中播放gif动画
- iOS应用内付费(IAP)开发步骤列表