RotationScreen.m 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. //
  2. // RotationScreen.m
  3. // AGPlayer
  4. //
  5. // Created by 吴书敏 on 16/8/3.
  6. // Copyright © 2016年 littledogboy. All rights reserved.
  7. //
  8. #import "RotationScreen.h"
  9. @implementation RotationScreen
  10. //
  11. + (void)forceOrientation:(UIInterfaceOrientation)orientation {
  12. // setOrientation: 私有方法强制横屏
  13. if ([[UIDevice currentDevice] respondsToSelector:@selector(setOrientation:)]) {
  14. SEL selector = NSSelectorFromString(@"setOrientation:");
  15. NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[UIDevice instanceMethodSignatureForSelector:selector]];
  16. [invocation setSelector:selector];
  17. [invocation setTarget:[UIDevice currentDevice]];
  18. int val = orientation;
  19. [invocation setArgument:&val atIndex:2];
  20. [invocation invoke];
  21. }
  22. }
  23. //
  24. + (BOOL)isOrientationLandscape {
  25. if (UIInterfaceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation)) {
  26. return YES;
  27. } else {
  28. return NO;
  29. }
  30. }
  31. @end