AAPLCatalogTableTableViewController.m 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. //
  2. // AAPLCatalogTableTableViewController.m
  3. // UICatalog
  4. //
  5. // Created by Ryan Olson on 7/17/14.
  6. #import "AAPLCatalogTableTableViewController.h"
  7. #if DEBUG
  8. // FLEX should only be compiled and used in debug builds.
  9. #import "FLEXManager.h"
  10. #endif
  11. @interface AAPLCatalogTableTableViewController ()
  12. - (void)registerViewControllerBasedOption;
  13. @end
  14. @implementation AAPLCatalogTableTableViewController
  15. - (void)viewDidLoad
  16. {
  17. [super viewDidLoad];
  18. #if DEBUG
  19. [self registerViewControllerBasedOption];
  20. self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"FLEX" style:UIBarButtonItemStylePlain target:self action:@selector(flexButtonTapped:)];
  21. #endif
  22. }
  23. - (void)flexButtonTapped:(id)sender
  24. {
  25. #if DEBUG
  26. // This call shows the FLEX toolbar if it's not already shown.
  27. [[FLEXManager sharedManager] showExplorer];
  28. #endif
  29. }
  30. - (void)registerViewControllerBasedOption
  31. {
  32. // create UIViewController subclass
  33. UIViewController *viewController = [[UIViewController alloc] init];
  34. // fill it with some stuff
  35. UILabel *infoLabel = [[UILabel alloc] init];
  36. infoLabel.translatesAutoresizingMaskIntoConstraints = NO;
  37. infoLabel.text = @"Add switches, notes or whatewer you wish to provide your testers with superpowers!";
  38. infoLabel.numberOfLines = 0;
  39. infoLabel.textAlignment = NSTextAlignmentCenter;
  40. UIView *view = viewController.view;
  41. view.backgroundColor = [UIColor whiteColor];
  42. [view addSubview:infoLabel];
  43. [view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-0-[infoLabel]-0-|"
  44. options:0
  45. metrics:nil
  46. views:NSDictionaryOfVariableBindings(infoLabel)]];
  47. [view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-0-[infoLabel]-0-|"
  48. options:0
  49. metrics:nil
  50. views:NSDictionaryOfVariableBindings(infoLabel)]];
  51. // return it in viewControllerFutureBlock
  52. [[FLEXManager sharedManager] registerGlobalEntryWithName:@"Custom superpowers"
  53. viewControllerFutureBlock:^id{
  54. return viewController;
  55. }];
  56. }
  57. @end