iOS UITableView 1
来源:互联网 发布:淘宝大学官方视频教程 编辑:程序博客网 时间:2024/06/06 23:16
1 ==================================创建
#pragma -mark创建tableView
- (void)createTableView{
- (void)createTableView{
= [[UITableViewalloc]initWithFrame:self.bounds];
[selfaddSubview:];
.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 = [[UITableViewCellalloc]init];
}
cell.backgroundColor= [UIColorclearColor];
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 = [[UITableViewCellalloc]init];
}
cell.backgroundColor= [UIColorclearColor];
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:niloptions: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 = [[UIImageViewalloc]initWithFrame:CGRectMake(0,0,WidthOfScreen,30)];
_headerTableView.image= [UIImageimageNamed:@"topmenu_tab_bg.png"];
UILabel*_mouthLabel = [[UILabelalloc]initWithFrame:_headerTableView.bounds];
[_headerTableView addSubview:_mouthLabel];
_mouthLabel.font= [UIFontsystemFontOfSize:20];
_mouthLabel.textColor= [UIColorwhiteColor];
//加载数据
NSString*month = _moviecomingsAllkeysArray[section];
NSLog(@"%@",month);
_mouthLabel.text= [NSStringstringWithFormat:@" %@月",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;
0 0
- IOS-UITableView入门(1)
- iOS-开发UITableView-1
- iOS UITableView 1
- iOS UITableView性能优化1
- iOS UITableView表视图(1)
- IOS UITableview
- ios UITableView
- iOS- UITableView
- ios UITableView
- IOS UITableView
- IOS UITableView
- Ios-UITableView
- iOS UITableView
- iOS UITableView
- IOS-UITableView
- IOS UITableView
- iOS-------UITableView
- iOS UITableView
- c++作业2
- robustMatch
- 开发环境配置-eclipse插件的安装与卸载-3
- UVA 540 —— Team Queue
- Android关于Socket通信异常的问题
- iOS UITableView 1
- 时间类1
- 蓝牙学习之旅——低功耗蓝牙之广播报文SCAN_REQ
- 【全排列 - 递归】
- BZOJ 4401(块的计数-树的划分)
- 完整java开发中JDBC连接数据库代码和步骤
- Android问题集锦之四十七: Error:Execution failed for task ':app:packageRelease'. > Unable to compute hash of
- 【HDOJ 5652】 India and China Origins(并查集)
- Prolog语言及程序设计