MASExampleListViewController.m 3.1 KB

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