CNCommonTableViewController.m
5.86 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
//
// CNCommonTableViewController.m
// CNLiveNetAdd
//
// Created by 张旭 on 2017/12/30.
// Copyright © 2017年 cnlive. All rights reserved.
//
#import "CNCommonTableViewController.h"
//#import "CNAttentionViewController.h"
//#import "CNMineHomeController.h"
#import "QMUIKit.h"
#import "CNThemeManager.h"
#import "CNLiveBaseKit.h"
@interface CNCommonTableViewController ()
@end
@implementation CNCommonTableViewController
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
// if ([self isKindOfClass:[CNAttentionViewController class]] || [self isKindOfClass:[CNMineHomeController class]]) {
// self.tabBarController.tabBar.hidden = NO;
// }else{
//
// self.tabBarController.tabBar.hidden = YES;
// }
// self.navigationController.interactivePopGestureRecognizer.delegate = (id)self;
}
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
}
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
[UIView setAnimationsEnabled:YES];
}
- (void)viewDidLoad
{
[super viewDidLoad];
// [self p_startNetworkMonitoring];
}
- (void)didInitialize {
[super didInitialize];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleThemeChangedNotification:) name:CNThemeChangedNotification object:nil];
}
- (void)initSubviews {
[super initSubviews];
if (@available(iOS 11.0, *)) {
self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
} else {
self.automaticallyAdjustsScrollViewInsets = NO;
}
self.tableView.top = kNavigationBarHeight;
self.tableView.height = KScreenHeight - kNavigationBarHeight - kVerticalTabBarTotalHeight;
}
- (void)setCNNoNetworkingEmptyView {
self.emptyView.backgroundColor = [UIColor whiteColor];
self.emptyView.actionButton.backgroundColor = UIColorMake(0, 194, 0);
self.emptyView.actionButton.layer.masksToBounds = YES;
self.emptyView.actionButton.layer.cornerRadius = 6;
self.emptyView.imageViewInsets = UIEdgeInsetsMake(0, 0, 15, 0);
self.emptyView.textLabelInsets = UIEdgeInsetsMake(0, 0, 14, 0);
self.emptyView.detailTextLabelInsets = UIEdgeInsetsMake(0, 0, 16, 0);
[self.emptyView setTextLabelFont:UIFontMake(17)];
[self.emptyView setDetailTextLabelFont:UIFontMake(13)];
[self.emptyView setTextLabelTextColor:UIColorMake(102, 102, 102)];
[self.emptyView setDetailTextLabelTextColor:UIColorMake(153, 153, 153)];
}
- (void)setCNAPIErrorEmptyView {
self.emptyView.actionButton.backgroundColor = UIColorMake(0, 194, 0);
self.emptyView.actionButton.layer.masksToBounds = YES;
self.emptyView.actionButton.layer.cornerRadius = 6;
self.emptyView.imageViewInsets = UIEdgeInsetsMake(0, 0, 15, 0);
self.emptyView.textLabelInsets = UIEdgeInsetsMake(0, 0, 14, 0);
self.emptyView.detailTextLabelInsets = UIEdgeInsetsMake(0, 0, 16, 0);
[self.emptyView setTextLabelFont:UIFontMake(17)];
[self.emptyView setDetailTextLabelFont:UIFontMake(13)];
[self.emptyView setTextLabelTextColor:UIColorMake(102, 102, 102)];
[self.emptyView setDetailTextLabelTextColor:UIColorMake(153, 153, 153)];
}
- (void)setCNNoDataEmptyView {
[self.emptyView setTextLabelFont:UIFontMake(17)];
[self.emptyView setTextLabelTextColor:UIColorMake(102, 102, 102)];
self.emptyView.imageViewInsets = UIEdgeInsetsMake(0, 0, 36, 0);
}
- (UIStatusBarStyle)preferredStatusBarStyle {
return UIStatusBarStyleDefault;
}
- (BOOL)shouldAutorotate {
return NO;
}
- (UIImage *)navigationBarBackgroundImage {
return [self imageWithColor:[UIColor whiteColor]];
}
- (UIImage *)imageWithColor:(UIColor *)color {
return [self imageWithColor:color size:CGSizeMake(1, 1)];
}
- (UIImage *)imageWithColor:(UIColor *)color size:(CGSize)size {
if (color == nil) {
return nil;
}
CGRect rect=CGRectMake(0.0f, 0.0f, size.width, size.height);
UIGraphicsBeginImageContext(rect.size);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context, [color CGColor]);
CGContextFillRect(context, rect);
UIImage *theImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return theImage;
}
- (UIInterfaceOrientationMask)supportedOrientationMask {
return UIInterfaceOrientationMaskPortrait;
}
- (BOOL)forceEnableInteractivePopGestureRecognizer {
return YES;
}
///// 开始网络监控
//- (void)p_startNetworkMonitoring
//{
// weakself
// AFNetworkReachabilityManager *manager = [AFNetworkReachabilityManager sharedManager];
// [manager setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
// if (status == AFNetworkReachabilityStatusUnknown || status == AFNetworkReachabilityStatusNotReachable) {
// [weakSelf cn_noNetworking];//没网
// }else
// {//有网
// [weakSelf cn_wifiOrWWANNetworking];
// }
//// [self.tableView reloadData];
// }];
// [manager startMonitoring];
//}
- (void)cn_noNetworking {//子类重写
}
- (void)cn_wifiOrWWANNetworking {//子类重写
}
- (void)handleThemeChangedNotification:(NSNotification *)notification {
NSObject<CNThemeProtocol> *themeBeforeChanged = notification.userInfo[CNThemeBeforeChangedName];
themeBeforeChanged = [themeBeforeChanged isKindOfClass:[NSNull class]] ? nil : themeBeforeChanged;
NSObject<CNThemeProtocol> *themeAfterChanged = notification.userInfo[CNThemeAfterChangedName];
themeAfterChanged = [themeAfterChanged isKindOfClass:[NSNull class]] ? nil : themeAfterChanged;
[self themeBeforeChanged:themeBeforeChanged afterChanged:themeAfterChanged];
}
#pragma mark - <CNChangingThemeDelegate>
- (void)themeBeforeChanged:(NSObject<CNThemeProtocol> *)themeBeforeChanged afterChanged:(NSObject<CNThemeProtocol> *)themeAfterChanged {
[self.tableView reloadData];
}
@end