AHKActionSheetViewController.m 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. #if __IPHONE_OS_VERSION_MAX_ALLOWED < 90000
  38. - (NSUInteger)supportedInterfaceOrientations
  39. #else
  40. - (UIInterfaceOrientationMask)supportedInterfaceOrientations
  41. #endif
  42. {
  43. return UIInterfaceOrientationMaskAll;
  44. }
  45. - (UIStatusBarStyle)preferredStatusBarStyle
  46. {
  47. UIWindow *window = self.actionSheet.previousKeyWindow;
  48. if (!window) {
  49. window = [[UIApplication sharedApplication].windows firstObject];
  50. }
  51. return [[window ahk_viewControllerForStatusBarStyle] preferredStatusBarStyle];
  52. }
  53. - (BOOL)prefersStatusBarHidden
  54. {
  55. UIWindow *window = self.actionSheet.previousKeyWindow;
  56. if (!window) {
  57. window = [[UIApplication sharedApplication].windows firstObject];
  58. }
  59. return [[window ahk_viewControllerForStatusBarHidden] prefersStatusBarHidden];
  60. }
  61. @end