怎么获取当前屏幕状态,如横屏左横右横
如何获取当前屏幕状态,如横屏左横右横?
请问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
设备方向
请问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
设备方向