-
Notifications
You must be signed in to change notification settings - Fork 193
/
RootViewController.m
93 lines (75 loc) · 2.62 KB
/
RootViewController.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
//
// ViewController.m
// BonMot
//
// Created by Zev Eisenberg on 04/17/2015.
// Copyright © 2015 Zev Eisenberg. All rights reserved.
//
#import "RootViewController.h"
// Cells
#import "ColorCell.h"
#import "TrackingCell.h"
#import "IndentationCell.h"
#import "LineHeightCell.h"
#import "FigureStyleCell.h"
#import "BaselineCapHeightCell.h"
#import "ProgrammaticBaselineCapHeightCell.h"
#import "InlineImagesCell.h"
#import "SpecialCharactersCell.h"
#import "BaselineOffsetCell.h"
#import "ConcatenationCell.h"
#import "TagStylesCell.h"
@interface RootViewController ()
@property (copy, nonatomic) BONGeneric(NSArray, Class) * cellClasses;
@end
@implementation RootViewController
- (void)viewDidLoad
{
[super viewDidLoad];
self.tableView.rowHeight = UITableViewAutomaticDimension;
self.tableView.estimatedRowHeight = 123.0;
self.cellClasses = @[
[ColorCell class],
[TrackingCell class],
[IndentationCell class],
[LineHeightCell class],
[FigureStyleCell class],
[BaselineCapHeightCell class],
[ProgrammaticBaselineCapHeightCell class],
[InlineImagesCell class],
[SpecialCharactersCell class],
[BaselineOffsetCell class],
[ConcatenationCell class],
[TagStylesCell class]
];
for (Class CellClass in self.cellClasses) {
NSAssert([CellClass respondsToSelector:@selector(reuseIdentifier)],
@"Cells must inherit from %@", NSStringFromClass([AbstractCell class]));
[self.tableView registerNib:[UINib nibWithNibName:NSStringFromClass(CellClass) bundle:nil]
forCellReuseIdentifier:[CellClass reuseIdentifier]];
}
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return self.cellClasses.count;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 1;
}
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
Class CellClass = self.cellClasses[section];
NSAssert([CellClass respondsToSelector:@selector(title)],
@"Cells must inherit from %@", NSStringFromClass([AbstractCell class]));
return [CellClass title];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
Class CellClass = self.cellClasses[indexPath.section];
NSAssert([CellClass respondsToSelector:@selector(reuseIdentifier)],
@"Cells must inherit from %@", NSStringFromClass([AbstractCell class]));
BaselineOffsetCell *cell = [tableView dequeueReusableCellWithIdentifier:[CellClass reuseIdentifier]];
return cell;
}
@end