首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > Iphone >

怎么获取当前屏幕状态,如横屏左横右横

2012-03-24 
如何获取当前屏幕状态,如横屏左横右横?请问Object-C如何获取当前屏幕的状态?我需要捕获屏幕到底是横屏还是

如何获取当前屏幕状态,如横屏左横右横?
请问Object-C如何获取当前屏幕的状态?
我需要捕获屏幕到底是横屏还是竖屏,还要分左横,右横。。。

多谢~

[解决办法]
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
 // Return YES for supported orientations
 return (interfaceOrientation == UIInterfaceOrientationPortrait);
 }

UIInterfaceOrientationPortrait 是一个枚举值,有四个状态值!你可以去查下
[解决办法]
以下这段代码可以用来判断 iPhone 屏幕的朝向 

@interface UIViewController (UIViewControllerRotation)
@property(nonatomic,readonly) UIInterfaceOrientation interfaceOrientation;
当前UIViewController的方向

UIKIT_EXTERN_CLASS @interface UIDevice : NSObject 
@property(nonatomic,readonly) UIDeviceOrientation orientation; // return current device orientation
设备方向

热点排行