MASExampleListViewController.m 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. //
  2. // MASExampleListViewController.h
  3. // Masonry
  4. //
  5. // Created by Jonas Budelmann on 21/07/13.
  6. // Copyright (c) 2013 cloudling. All rights reserved.
  7. //
  8. #import "MASExampleListViewController.h"
  9. #import "MASExampleViewController.h"
  10. #import "MASExampleBasicView.h"
  11. #import "MASExampleConstantsView.h"
  12. #import "MASExampleSidesView.h"
  13. #import "MASExampleAnimatedView.h"
  14. #import "MASExampleDebuggingView.h"
  15. #import "MASExampleLabelView.h"
  16. #import "MASExampleUpdateView.h"
  17. #import "MASExampleRemakeView.h"
  18. #import "MASExampleScrollView.h"
  19. #import "MASExampleLayoutGuideViewController.h"
  20. #import "MASExampleArrayView.h"
  21. #import "MASExampleAttributeChainingView.h"
  22. static NSString * const kMASCellReuseIdentifier = @"kMASCellReuseIdentifier";
  23. @interface MASExampleListViewController ()
  24. @property (nonatomic, strong) NSArray *exampleControllers;
  25. @end
  26. @implementation MASExampleListViewController
  27. - (id)init {
  28. self = [super init];
  29. if (!self) return nil;
  30. self.title = @"Examples";
  31. self.exampleControllers = @[
  32. [[MASExampleViewController alloc] initWithTitle:@"Basic"
  33. viewClass:MASExampleBasicView.class],
  34. [[MASExampleViewController alloc] initWithTitle:@"Update Constraints"
  35. viewClass:MASExampleUpdateView.class],
  36. [[MASExampleViewController alloc] initWithTitle:@"Remake Constraints"
  37. viewClass:MASExampleRemakeView.class],
  38. [[MASExampleViewController alloc] initWithTitle:@"Using Constants"
  39. viewClass:MASExampleConstantsView.class],
  40. [[MASExampleViewController alloc] initWithTitle:@"Composite Edges"
  41. viewClass:MASExampleSidesView.class],
  42. [[MASExampleViewController alloc] initWithTitle:@"Basic Animated"
  43. viewClass:MASExampleAnimatedView.class],
  44. [[MASExampleViewController alloc] initWithTitle:@"Debugging Helpers"
  45. viewClass:MASExampleDebuggingView.class],
  46. [[MASExampleViewController alloc] initWithTitle:@"Bacony Labels"
  47. viewClass:MASExampleLabelView.class],
  48. [[MASExampleViewController alloc] initWithTitle:@"UIScrollView"
  49. viewClass:MASExampleScrollView.class],
  50. [[MASExampleViewController alloc] initWithTitle:@"Array"
  51. viewClass:MASExampleArrayView.class],
  52. [[MASExampleViewController alloc] initWithTitle:@"Attribute Chaining"
  53. viewClass:MASExampleAttributeChainingView.class],
  54. [[MASExampleLayoutGuideViewController alloc] init],
  55. ];
  56. return self;
  57. }
  58. - (void)viewDidLoad {
  59. [super viewDidLoad];
  60. self.view.backgroundColor = [UIColor whiteColor];
  61. [self.tableView registerClass:UITableViewCell.class forCellReuseIdentifier:kMASCellReuseIdentifier];
  62. }
  63. #pragma mark - UITableViewDataSource
  64. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  65. UIViewController *viewController = self.exampleControllers[indexPath.row];
  66. UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:kMASCellReuseIdentifier forIndexPath:indexPath];
  67. cell.textLabel.text = viewController.title;
  68. return cell;
  69. }
  70. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  71. return self.exampleControllers.count;
  72. }
  73. #pragma mark - UITableViewDelegate
  74. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  75. UIViewController *viewController = self.exampleControllers[indexPath.row];
  76. [self.navigationController pushViewController:viewController animated:YES];
  77. }
  78. @end