forked from liangfenxiaodao/UIDynamicExample
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainViewController.m
More file actions
50 lines (41 loc) · 1.77 KB
/
MainViewController.m
File metadata and controls
50 lines (41 loc) · 1.77 KB
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
#import "MainViewController.h"
#import "GeneralViewController.h"
#define keyItemName @"name"
#define keyClassName @"class"
@implementation MainViewController {
NSArray *items;
}
- (id)init {
self = [super init];
if (self) {
items = [self setupItems];
[self.navigationItem setTitle:@"Dynamic Behaviours"];
}
return self;
}
- (NSArray *)setupItems {
return @[@{keyItemName : @"Gravity", keyClassName : @"GravityView"},
@{keyItemName : @"Collision", keyClassName : @"CollisionView"},
@{keyItemName : @"Attachment", keyClassName : @"AttachmentView"},
@{keyItemName : @"Advanced Attachment", keyClassName : @"AdvancedAttachmentView"},
@{keyItemName : @"Snap", keyClassName : @"SnapView"},
@{keyItemName : @"Push", keyClassName : @"PushView"}];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
if (!cell) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
}
[cell.textLabel setText:items[[indexPath row]][keyItemName]];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
return cell;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [items count];
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSDictionary *item = items[[indexPath row]];
GeneralViewController *viewController = [[GeneralViewController alloc] initWithViewName:item[keyClassName] andTitle:item[keyItemName]];
[[self navigationController] pushViewController:viewController animated:NO];
}
@end