-
Notifications
You must be signed in to change notification settings - Fork 0
/
WeiboTableView.m
78 lines (55 loc) · 1.96 KB
/
WeiboTableView.m
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
//
// WeiboTableView.m
// WeiChi
//
// Created by imac on 15/9/11.
// Copyright (c) 2015年 imac. All rights reserved.
//
#import "WeiboTableView.h"
#import "WeiboCell.h"
#import "WeiboModel.h"
#import "DetailViewController.h"
#import "UIView+ViewController.h"
@implementation WeiboTableView
-(instancetype)initWithFrame:(CGRect)frame style:(UITableViewStyle)style{
self = [super initWithFrame:frame style:style];
if(self){
[self initTable];
}
return self;
}
-(void)awakeFromNib{
[self initTable];
}
- (void)initTable{
self.delegate = self;
self.dataSource = self;
//注册单元格
UINib *nib = [UINib nibWithNibName:@"WeiboCell" bundle:nil];
[self registerNib:nib forCellReuseIdentifier:@"weiboCell"];
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return _layoutFrameArray.count ;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
WeiboCell *cell = [tableView dequeueReusableCellWithIdentifier:@"weiboCell" forIndexPath:indexPath];
//获得某个cell的布局对象
WeiboViewLayoutFrame *layoutFrame = _layoutFrameArray[indexPath.row];
cell.layoutFrame = layoutFrame;
return cell;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
WeiboViewLayoutFrame *layoutFrame = _layoutFrameArray[indexPath.row];
CGFloat height = layoutFrame.frame.size.height;
return height +80;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
DetailViewController *vc=[[DetailViewController alloc]init];
WeiboViewLayoutFrame *layoutFrame = _layoutFrameArray[indexPath.row];
vc.weiboModel = layoutFrame.weiboModel;
[self.viewController.navigationController pushViewController:vc animated:YES];
}
@end