AAPLCatalogTableTableViewController.m 2.3 KB

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