CNMyViewController.m
9.47 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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
//
// CNMyViewController.m
// CNLiveScioLive
//
// Created by CNLive-zxw on 2018/9/18.
// Copyright © 2018年 CNLive. All rights reserved.
//
#import "CNMyViewController.h"
#import "CNMyTableViewHeaderView.h"
#import "CNMyTableViewCell.h"
#import "CNMyAnnouncementsViewController.h"//通知公告
#import "CNLiveSettingViewController.h"//设置
#import "CNLiveContactUsViewController.h"//联系我们
#import "CNLiveMyCollectionViewController.h"
#import "CNLiveCertificatesViewController.h"
#import "CNLiveUserSettingViewController.h"//用户设置
@interface CNMyViewController ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) NSArray *titles;
@property (nonatomic, strong) NSArray *pics;
@end
@implementation CNMyViewController
static NSString *identifier = @"CNMyTableViewCell";
-(void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@""] forBarMetrics:UIBarMetricsDefault];
}
-(void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
UIImage *backGroundImage = [UIImage imageNamed:@"cnlive_headerBack"];
backGroundImage = [backGroundImage resizableImageWithCapInsets:UIEdgeInsetsZero resizingMode:UIImageResizingModeStretch];
[self.navigationController.navigationBar setBackgroundImage:backGroundImage forBarMetrics:UIBarMetricsDefault];
}
- (void)viewDidLoad {
[super viewDidLoad];
self.navigationController.navigationBar.barTintColor = [UIColor whiteColor];
self.name = CustomStr(@"PersonalCenter");
[self.view addSubview:self.tableView];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeLanguageVersion:) name:@"changeLanguageVersion" object:nil];
}
- (void)changeLanguageVersion:(NSNotification *)notification {
self.name = CustomStr(@"PersonalCenter");
[self.tableView reloadData];
}
- (void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self name:@"changeLanguageVersion" object:nil];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark - UITableViewDelegate
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
return 45;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
return 10;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
return 0.00000001f;
}
#pragma mark - UITableViewDataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
return self.titles.count;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
NSArray *data = self.titles[section];
return data.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
// NSArray *name = @[@[CustomStr(@"Announcements"), CustomStr(@"MyFavorite")],@[CustomStr(@"ContactUs")],@[CustomStr(@"Settings")]];
// NSArray *pic = @[@[@"cnlive_my_news", @"cnlive_my_collection"],@[@"cnlive_my_tel"],@[@"cnlive_my_setting"]];
CNMyTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
if (!cell) {
cell = [[CNMyTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
}
cell.selectionStyle = UITableViewCellSelectionStyleNone;
cell.name = self.titles[indexPath.section][indexPath.row];
cell.pic = self.pics[indexPath.section][indexPath.row];
return cell;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
UIView *headerView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, MainScreenWidth, 10)];
headerView.backgroundColor = HEXCOLOR(0xebebeb);
return headerView;
}
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
UIView *footerView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, MainScreenWidth, 0.00000001f)];
footerView.backgroundColor = HEXCOLOR(0xebebeb);
return footerView;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if(indexPath.section == 0){
if(indexPath.row == 0){
//通知公告
CNMyAnnouncementsViewController *vc = [CNMyAnnouncementsViewController new];
vc.navTitle = CustomStr(@"Announcements");
vc.hidesBottomBarWhenPushed = YES;
[self.navigationController pushViewController:vc animated:YES];
}else if (indexPath.row == 1){
//我的收藏
CNLiveMyCollectionViewController *vc = [CNLiveMyCollectionViewController new];
vc.navTitle = CustomStr(@"MyFavorite");
vc.hidesBottomBarWhenPushed = YES;
[self.navigationController pushViewController:vc animated:YES];
}
return;
}else if (indexPath.section == 1){
if(indexPath.row == 0){
//证件申领
// CNLiveCertificatesViewController *vc = [CNLiveCertificatesViewController new];
// vc.hidesBottomBarWhenPushed = YES;
// [self.navigationController pushViewController:vc animated:YES];
// CNLiveWebViewController *vc = [CNLiveWebViewController new];
// vc.navTitle = CustomStr(@"Certificates");
// vc.url = @"http://219.142.85.77/index.html";
// vc.navTitle = CustomStr(@"Certificates");
// vc.hidesBottomBarWhenPushed = YES;
// [self.navigationController pushViewController:vc animated:YES];
CNLiveContactUsViewController *vc = [CNLiveContactUsViewController new];
vc.navTitle = CustomStr(@"ContactUs");
vc.hidesBottomBarWhenPushed = YES;
[self.navigationController pushViewController:vc animated:YES];
}else if (indexPath.row == 1){
//联系我们
// CNLiveContactUsViewController *vc = [CNLiveContactUsViewController new];
// vc.navTitle = CustomStr(@"ContactUs");
// vc.hidesBottomBarWhenPushed = YES;
// [self.navigationController pushViewController:vc animated:YES];
}
return;
}else if (indexPath.section == 2){
//设置
CNLiveSettingViewController *vc = [CNLiveSettingViewController new];
vc.navTitle = CustomStr(@"Settings");
vc.hidesBottomBarWhenPushed = YES;
[self.navigationController pushViewController:vc animated:YES];
}
}
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
#pragma mark - Action
#pragma mark - Lazy Laoding
- (UITableView *)tableView{
if(!_tableView){
_tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, MainScreenWidth, MainScreenHeight - NavBarHeight) style:UITableViewStyleGrouped];
_tableView.scrollEnabled = NO;
_tableView.delegate = self;
_tableView.dataSource = self;
_tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
_tableView.backgroundColor = HEXCOLOR(0xebebeb);
_tableView.estimatedRowHeight = 0;
_tableView.estimatedSectionHeaderHeight = 0;
_tableView.estimatedSectionFooterHeight = 0;
CNMyTableViewHeaderView *headerView = [[CNMyTableViewHeaderView alloc]initWithFrame:CGRectMake(0, 0, MainScreenWidth, 150)];
headerView.backgroundColor = Color_Blue;
headerView.block = ^{
if ([[ZXWUserInformation shareZXWUserInformation] isLogin]){
CNLiveUserSettingViewController *vc = [CNLiveUserSettingViewController new];
vc.hidesBottomBarWhenPushed = YES;
[self.navigationController pushViewController:vc animated:YES];
}else{
CNLiveLoginViewController *vc = [CNLiveLoginViewController new];
vc.hidesBottomBarWhenPushed = YES;
[self.navigationController pushViewController:vc animated:YES];
}
};
_tableView.tableHeaderView = headerView;
[_tableView registerClass:[CNMyTableViewCell class] forCellReuseIdentifier:identifier];
}
return _tableView;
}
// NSArray *name = @[@[@"通知公告", @"我的收藏"],@[@"证件申领", @"联系我们"],@[@"设置"]];
// NSArray *name = @[@[CustomStr(@"Announcements"), CustomStr(@"MyFavorite")],@[CustomStr(@"Certificates"), CustomStr(@"ContactUs")],@[CustomStr(@"Settings")]];
// NSArray *pic = @[@[@"cnlive_my_news", @"cnlive_my_collection"],@[@"cnlive_my_certificate", @"cnlive_my_tel"],@[@"cnlive_my_setting"]];
- (NSArray *)titles{
if(!_titles){
NSArray *name = @[@[CustomStr(@"Announcements"), CustomStr(@"MyFavorite")],@[CustomStr(@"ContactUs")],@[CustomStr(@"Settings")]];
_titles = [[NSArray alloc] initWithArray:name];
}
return _titles;
}
- (NSArray *)pics{
if(!_pics){
NSArray *pic = @[@[@"cnlive_my_news", @"cnlive_my_collection"],@[@"cnlive_my_tel"],@[@"cnlive_my_setting"]];
_pics = [[NSArray alloc] initWithArray:pic];
}
return _pics;
}
@end