AHKActionSheetViewController.m 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. @interface AHKActionSheetViewController ()
  11. @property (nonatomic) BOOL viewAlreadyAppear;
  12. @end
  13. @implementation AHKActionSheetViewController
  14. #pragma mark - UIViewController
  15. - (void)viewDidLoad
  16. {
  17. [super viewDidLoad];
  18. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didRotateDeviceChangeNotification:) name:UIDeviceOrientationDidChangeNotification object:nil];
  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. -(void)didRotateDeviceChangeNotification:(NSNotification *)notification
  46. {
  47. [self.actionSheet dismissAnimated:NO];
  48. }
  49. @end