ViewController.m 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /**
  2. * Copyright (c) 2015-present, Facebook, Inc.
  3. * All rights reserved.
  4. *
  5. * This source code is licensed under the BSD-style license found in the
  6. * LICENSE file in the root directory of this source tree. An additional grant
  7. * of patent rights can be found in the PATENTS file in the same directory.
  8. */
  9. #import "ViewController.h"
  10. @interface ViewController ()
  11. @property (weak, nonatomic) IBOutlet UILabel *orentationLabel;
  12. @end
  13. @implementation ViewController
  14. - (IBAction)deadlockApp:(id)sender
  15. {
  16. dispatch_sync(dispatch_get_main_queue(), ^{
  17. // This will never execute
  18. });
  19. }
  20. - (IBAction)didTapButton:(UIButton *)button
  21. {
  22. button.selected = !button.selected;
  23. }
  24. - (void)viewDidLayoutSubviews
  25. {
  26. [super viewDidLayoutSubviews];
  27. [self updateOrentationLabel];
  28. }
  29. #if !TARGET_OS_TV
  30. - (void)updateOrentationLabel
  31. {
  32. NSString *orientation = nil;
  33. switch (UIDevice.currentDevice.orientation) {
  34. case UIInterfaceOrientationPortrait:
  35. orientation = @"Portrait";
  36. break;
  37. case UIInterfaceOrientationPortraitUpsideDown:
  38. orientation = @"PortraitUpsideDown";
  39. break;
  40. case UIInterfaceOrientationLandscapeLeft:
  41. orientation = @"LandscapeLeft";
  42. break;
  43. case UIInterfaceOrientationLandscapeRight:
  44. orientation = @"LandscapeRight";
  45. break;
  46. case UIDeviceOrientationFaceUp:
  47. orientation = @"FaceUp";
  48. break;
  49. case UIDeviceOrientationFaceDown:
  50. orientation = @"FaceDown";
  51. break;
  52. case UIInterfaceOrientationUnknown:
  53. orientation = @"Unknown";
  54. break;
  55. }
  56. self.orentationLabel.text = orientation;
  57. }
  58. #endif
  59. @end