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

解决方案 »

  1.   

    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
     // Return YES for supported orientations
     return (interfaceOrientation == UIInterfaceOrientationPortrait);
     }UIInterfaceOrientationPortrait 是一个枚举值,有四个状态值!你可以去查下
      

  2.   

    通过获取电池条的方向来判断设备方向
    uidevice currentdevice 的orientation就可以读出设备方向
    还可以计算设备的角度
    http://blog.csdn.net/ArthurChenJS/archive/2011/04/24/6358511.aspx
      

  3.   

    是的,UIApplication和UIDevice中可以获取到
      

  4.   

    以下这段代码可以用来判断 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
    设备方向