MASExampleListViewController.m 3.4 KB

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