CNLiveBeltRoadViewController.m
3.91 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
//
// CNLiveBeltRoadViewController.m
// CNLiveScioLive
//
// Created by CNLive-zxw on 2018/9/18.
// Copyright © 2018年 CNLive. All rights reserved.
//
#import "CNLiveBeltRoadViewController.h"
#import "CNLiveHeraldedNewsTableViewCell.h"
@interface CNLiveBeltRoadViewController ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) NSMutableArray *data;
@end
@implementation CNLiveBeltRoadViewController
static NSString *heraldedNewsTableViewCell = @"CNLiveHeraldedNewsTableViewCell";
#pragma mark - Data
- (void)loadData{
[_tableView.mj_header endRefreshing];
}
- (void)loadMoreData{
[_tableView.mj_footer endRefreshingWithNoMoreData];
}
- (void)viewDidLoad {
[super viewDidLoad];
[self.view addSubview:self.tableView];
// Do any additional setup after loading the view.
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark - UITableViewDelegate
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
return 80;//
}
#pragma mark - UITableViewDataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return self.data.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
CNLiveHeraldedNewsTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:heraldedNewsTableViewCell];
if (!cell) {
cell = [[CNLiveHeraldedNewsTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:heraldedNewsTableViewCell];
}
cell.selectionStyle = UITableViewCellSelectionStyleNone;
cell.model = self.data[indexPath.row];
return cell;
}
/*
#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 - Lazy Laoding
- (UITableView *)tableView{
if(!_tableView){
_tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, MainScreenWidth, MainScreenHeight-45-NavBarHeight-TabBarHeight) style:UITableViewStylePlain];
_tableView.delegate = self;
_tableView.dataSource = self;
_tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
_tableView.backgroundColor = HEXCOLOR(0xebebeb);
[_tableView registerClass:[CNLiveHeraldedNewsTableViewCell class] forCellReuseIdentifier:heraldedNewsTableViewCell];
_tableView.estimatedRowHeight = 0;
_tableView.estimatedSectionHeaderHeight = 0;
_tableView.estimatedSectionFooterHeight = 0;
// 设置上拉加载
MJRefreshGifHeader *header = [MJRefreshGifHeader headerWithRefreshingTarget:self refreshingAction:@selector(loadData)];
header.lastUpdatedTimeLabel.hidden = YES;
header.stateLabel.hidden = YES;
_tableView.mj_header = header;
// 设置下拉刷新
MJRefreshAutoNormalFooter *footer = [MJRefreshAutoNormalFooter footerWithRefreshingTarget:self refreshingAction:@selector(loadMoreData)];
[footer setTitle:CustomStr(@"RefreshBackFooterIdleText") forState:MJRefreshStateIdle];
[footer setTitle:CustomStr(@"RefreshBackFooterPullingText") forState:MJRefreshStatePulling];
[footer setTitle:CustomStr(@"RefreshBackFooterRefreshingText") forState:MJRefreshStateRefreshing];
[footer setTitle:CustomStr(@"RefreshBackFooterNoMoreDataText") forState:MJRefreshStateNoMoreData];
_tableView.mj_footer = footer;
}
return _tableView;
}
- (NSMutableArray *)data{
if(!_data){
_data = [[NSMutableArray alloc] init];
}
return _data;
}
@end