AHKActionSheetViewController.m 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. //
  2. // AHKActionSheetViewController.m
  3. // AHKActionSheetExample
  4. //
  5. // Created by Arkadiusz on 09-04-14.
  6. // Copyright (c) 2014 Arkadiusz Holko. All rights reserved.
  7. //
  8. #import "AHKActionSheetViewController.h"
  9. #import "AHKActionSheet.h"
  10. #import "UIWindow+AHKAdditions.h"
  11. @interface AHKActionSheetViewController ()
  12. @property (nonatomic) BOOL viewAlreadyAppear;
  13. @end
  14. @implementation AHKActionSheetViewController
  15. #pragma mark - UIViewController
  16. - (void)viewDidLoad
  17. {
  18. [super viewDidLoad];
  19. [self.view addSubview:self.actionSheet];
  20. self.actionSheet.frame = self.view.bounds;
  21. }
  22. - (void)viewDidAppear:(BOOL)animated
  23. {
  24. [super viewDidAppear:animated];
  25. self.viewAlreadyAppear = YES;
  26. }
  27. - (void)viewWillLayoutSubviews
  28. {
  29. [super viewWillLayoutSubviews];
  30. self.actionSheet.frame = self.view.bounds;
  31. }
  32. - (BOOL)shouldAutorotate
  33. {
  34. // doesn't allow autorotation after the view did appear (rotation messes up a blurred background)
  35. return !self.viewAlreadyAppear;
  36. }
  37. //TWS
  38. #if __IPHONE_OS_VERSION_MAX_ALLOWED < 90000
  39. - (NSUInteger)supportedInterfaceOrientations
  40. #else
  41. - (UIInterfaceOrientationMask)supportedInterfaceOrientations
  42. #endif
  43. {
  44. return UIInterfaceOrientationMaskAll;
  45. }
  46. - (UIStatusBarStyle)preferredStatusBarStyle
  47. {
  48. UIWindow *window = self.actionSheet.previousKeyWindow;
  49. if (!window) {
  50. window = [[UIApplication sharedApplication].windows firstObject];
  51. }
  52. return [[window ahk_viewControllerForStatusBarStyle] preferredStatusBarStyle];
  53. }
  54. - (BOOL)prefersStatusBarHidden
  55. {
  56. UIWindow *window = self.actionSheet.previousKeyWindow;
  57. if (!window) {
  58. window = [[UIApplication sharedApplication].windows firstObject];
  59. }
  60. return [[window ahk_viewControllerForStatusBarHidden] prefersStatusBarHidden];
  61. }
  62. @end