1 ==================================创建
#pragma -mark
创建tableView
- (void)createTableView{
- (void)createTableView{
= [[UITableView
alloc]initWithFrame:self.bounds];
[self
addSubview:];
.backgroundColor
= [UIColor clearColor];
.delegate
= self;
.dataSource
= self;
.rowHeight
= 120;
}
2 =======================代理
2.1==============通用方法
#pragma -mark cell number
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return 10;
}
#pragma -mark cell
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cinema_cell"];
if(cell == nil){
cell = [[UITableViewCell alloc]init];
}
cell.backgroundColor = [UIColor clearColor];
return cell;
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return 10;
}
#pragma -mark cell
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cinema_cell"];
if(cell == nil){
cell = [[UITableViewCell alloc]init];
}
cell.backgroundColor = [UIColor clearColor];
return cell;
}
2.2=================================XIB
#pragma -mark cell number
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
NSString *month = _moviecomingsAllkeysArray[section];
NSArray *movies = _moviecomingsModelDic[month];
return movies.count;
}
#pragma -mark cell ======== 注意两个cell
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
WillPlayTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"willplay_cell"];
if(cell == nil){
cell = [[[NSBundle mainBundle]loadNibNamed:@"WillPlayTableViewCell" owner:nil options:nil]lastObject];
cell.backgroundColor = [UIColor clearColor];
}
NSString *month = _moviecomingsAllkeysArray[indexPath.section];
NSArray *movies = _moviecomingsModelDic[month];
MovieComingsModel *model = movies[indexPath.row];
cell.model = model;
return cell;
}
2.3================storyBoard tbaleViewControl 控件根据tag值确定
UITableViewCell
*cell = [tableView
dequeueReusableCellWithIdentifier:@"friedList_cell"
forIndexPath:indexPath];
3 ======================================== 关于组的方法
#pragma -mark tableView
组的头视图
- (UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
UIImageView *_headerTableView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, WidthOfScreen, 30)];
_headerTableView.image = [UIImage imageNamed:@"topmenu_tab_bg.png"];
UILabel *_mouthLabel = [[UILabel alloc]initWithFrame:_headerTableView.bounds];
[_headerTableView addSubview:_mouthLabel];
_mouthLabel.font = [UIFont systemFontOfSize:20];
_mouthLabel.textColor = [UIColor whiteColor];
//加载数据
NSString *month = _moviecomingsAllkeysArray[section];
NSLog(@"%@",month);
_mouthLabel.text = [NSString stringWithFormat:@" %@月",month];
// _mouthLabel.text = month; == 不一定是String型的
return _headerTableView;
}
#pragma -mark
设置组头的高
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
return 30;
}
#pragma -mark
设置组数
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
return _moviecomingsAllkeysArray.count;
}
5 ==========================头视图
_willPalyTableView.tableHeaderView
= _headView;