MASExampleListViewController.m 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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 "MASExampleScrollView.h"
  18. #import "MASExampleLayoutGuideViewController.h"
  19. #import "MASExampleArrayView.h"
  20. #import "MASExampleAttributeChainingView.h"
  21. static NSString * const kMASCellReuseIdentifier = @"kMASCellReuseIdentifier";
  22. @interface MASExampleListViewController ()
  23. @property (nonatomic, strong) NSArray *exampleControllers;
  24. @end
  25. @implementation MASExampleListViewController
  26. - (id)init {
  27. self = [super init];
  28. if (!self) return nil;
  29. self.title = @"Examples";
  30. self.exampleControllers = @[
  31. [[MASExampleViewController alloc] initWithTitle:@"Basic"
  32. viewClass:MASExampleBasicView.class],
  33. [[MASExampleViewController alloc] initWithTitle:@"Update Constraints"
  34. viewClass:MASExampleUpdateView.class],
  35. [[MASExampleViewController alloc] initWithTitle:@"Using Constants"
  36. viewClass:MASExampleConstantsView.class],
  37. [[MASExampleViewController alloc] initWithTitle:@"Composite Edges"
  38. viewClass:MASExampleSidesView.class],
  39. [[MASExampleViewController alloc] initWithTitle:@"Basic Animated"
  40. viewClass:MASExampleAnimatedView.class],
  41. [[MASExampleViewController alloc] initWithTitle:@"Debugging Helpers"
  42. viewClass:MASExampleDebuggingView.class],
  43. [[MASExampleViewController alloc] initWithTitle:@"Bacony Labels"
  44. viewClass:MASExampleLabelView.class],
  45. [[MASExampleViewController alloc] initWithTitle:@"UIScrollView"
  46. viewClass:MASExampleScrollView.class],
  47. [[MASExampleViewController alloc] initWithTitle:@"Array"
  48. viewClass:MASExampleArrayView.class],
  49. [[MASExampleViewController alloc] initWithTitle:@"Attribute Chaining"
  50. viewClass:MASExampleAttributeChainingView.class],
  51. [[MASExampleLayoutGuideViewController alloc] init],
  52. ];
  53. return self;
  54. }
  55. - (void)viewDidLoad {
  56. [super viewDidLoad];
  57. self.view.backgroundColor = [UIColor whiteColor];
  58. [self.tableView registerClass:UITableViewCell.class forCellReuseIdentifier:kMASCellReuseIdentifier];
  59. }
  60. #pragma mark - UITableViewDataSource
  61. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  62. UIViewController *viewController = self.exampleControllers[indexPath.row];
  63. UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:kMASCellReuseIdentifier forIndexPath:indexPath];
  64. cell.textLabel.text = viewController.title;
  65. return cell;
  66. }
  67. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  68. return self.exampleControllers.count;
  69. }
  70. #pragma mark - UITableViewDelegate
  71. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  72. UIViewController *viewController = self.exampleControllers[indexPath.row];
  73. [self.navigationController pushViewController:viewController animated:YES];
  74. }
  75. @end