AAPLCatalogTableTableViewController.m 2.4 KB

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