MASExampleListViewController.m 3.3 KB

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