Repository navigation
Expand file tree
/
Copy pathMSYViewController.m
More file actions
127 lines (95 loc) · 3.77 KB
/
Copy pathMSYViewController.m
File metadata and controls
127 lines (95 loc) · 3.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
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
//
// MSYViewController.m
// MSYTableView
//
// Created by SimonMiao on 08/20/2021.
// Copyright (c) 2021 SimonMiao. All rights reserved.
//
#import "MSYViewController.h"
#import <Masonry/Masonry.h>
#import <MSYTableView/MSYCommonTableView.h>
#import <MSYTableView/MSYCommonTableData.h>
#import <MSYTableView/MSYTableViewProtocol.h>
#import "MSYExampleViewController.h"
static NSString *const kTitle_system = @"系统自带cell";
static NSString *const kTitle_custom = @"自定义的cell";
static NSString *const kTitle_refresh = @"上拉下拉的cell";
@interface MSYViewController () <MSYTableViewProtocol>
@property (nonatomic, strong) MSYCommonTableView *homeView;
@end
@implementation MSYViewController
#pragma mark - lifecycle methods
- (void)viewDidLoad
{
[super viewDidLoad];
self.title = @"Example";
[self.view addSubview:self.homeView];
[self initConstraints];
[self loadDataSource];
}
#pragma mark - public methods
#pragma mark - private methods
- (void)initConstraints {
[self.homeView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.mas_equalTo(self.view);
}];
}
- (void)loadDataSource {
NSArray *historyList = @[kTitle_system, kTitle_custom, kTitle_refresh];
NSMutableArray *sectionDicArr = [NSMutableArray arrayWithCapacity:0];
NSMutableArray *rowDicArr = [NSMutableArray arrayWithCapacity:0];
for (NSString *text in historyList) {
NSDictionary *rowDic = @{
kRow_title : text ? : @"",
kRow_detailTitle : @"",
kRow_rowHeight : @(44),
kRow_sepLeftEdge : @(100)
};
[rowDicArr addObject:rowDic];
}
NSDictionary *sectionDic = @{
kSec_headerTitle : @"案例介绍",
kSec_headerHeight : @(33),
kSec_footerHeight : @(kSectionHeaderHeight_zero),
kSec_rowContent : rowDicArr,
};
[sectionDicArr addObject:sectionDic];
NSArray *sections = [MSYCommonTableSection sectionsWithData:sectionDicArr];
self.homeView.dataSource = sections;
}
#pragma mark - MSYTableViewProtocol
- (void)msy_tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
MSYCommonTableSection *secionModel = self.homeView.dataSource[indexPath.section];
MSYCommonTableRow *rowModel = secionModel.rows[indexPath.row];
if ([rowModel.title isEqualToString:kTitle_system]) {
MSYExampleViewController *ctr = [[MSYExampleViewController alloc] init];
ctr.title = rowModel.title;
ctr.exampleType = MSYExampleType_system;
[self.navigationController pushViewController:ctr animated:YES];
}
else if ([rowModel.title isEqualToString:kTitle_custom]) {
MSYExampleViewController *ctr = [[MSYExampleViewController alloc] init];
ctr.title = rowModel.title;
ctr.exampleType = MSYExampleType_custom;
[self.navigationController pushViewController:ctr animated:YES];
}
else if ([rowModel.title isEqualToString:kTitle_refresh]) {
MSYExampleViewController *ctr = [[MSYExampleViewController alloc] init];
ctr.title = rowModel.title;
ctr.exampleType = MSYExampleType_refresh;
[self.navigationController pushViewController:ctr animated:YES];
}
else {
}
}
#pragma mark - getter && setter
- (MSYCommonTableView *)homeView {
if (!_homeView) {
_homeView = [[MSYCommonTableView alloc] initWithStyle:UITableViewStylePlain cellStyle:UITableViewCellStyleSubtitle];
_homeView.isHideSystemSeparator = YES;//是否隐藏系统分离线
_homeView.isShowCustomSeparator = YES;//是否显示自定义分离线
_homeView.customSeparatorColor = [UIColor redColor];//自定义分离线颜色
}
return _homeView;
}
@end