ios - UITableViewController 笔记
来源:互联网 发布:战舰世界2017岛风数据 编辑:程序博客网 时间:2024/05/22 06:26
如果是在ViewContorller上使用 UITableView 则需要在.h文件实现表示图的
两个代理<UITableViewDelegate,UITableViewDataSource>
其中,dataSource是管理表示图显示多少行,跟每一行的内容的代理。
tableView:cellForRowAtIndexPath方法
tableView:numberOfRowsInSection方法
而delegate则是管理表示图的行高,行距,节点,表头,表底等等一些设置的。
UITbalView的各种方法总结:
//section节数
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
return 1;
}
//每个section的标题 名字
- (NSString*)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{
return [abcArray objectAtIndex:section];
}
//右侧 索引
- (NSArray*)sectionIndexTitlesForTableView:(UITableView *)tableView{
return abcArray;
}
//返回Section标题内容
-(NSString *)tableView:(UITableView *)tableViewtitleForHeaderInSection:(NSInteger)section{
}
}
//section里面每一行的内容
-(UITableViewCell *)tableView:(UITableView *)tableViewcellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *cellIndentifier = @"DatasCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIndentifier];
if (!cell) {
cell = [[UITableViewCellalloc]initWithStyle:UITableViewCellStyleDefaultreuseIdentifier:cellIndentifier];
//:UITableViewCell有4种style,default只显示image和文本标签;subtitle显示image,文本标签和详细文本(位于文本标签下方);value1显示image,文本标签和详细文本(位于文本标签右边);value2只显示文本标签和详细文本(文本标签小字体,详细文本粗体)
//分割线的样式:UITableViewCellSeparatorStyleNone 无分割线,UITableViewCellSeparatorStyleSingleLine 单分割线,UITableViewCellSeparatorStyleSingleLineEtched 被侵蚀的单分割线
}
cell.textLabel.text = [carsNameArrayobjectAtIndex:indexPath.row];
cell.imageView.image = [UIImage imageNamed:[NSStringstringWithFormat:@"Audi.png"]];
return cell;
}
//一共有多少行
-(NSInteger)tableView:(UITableView *)tableViewnumberOfRowsInSection:(NSInteger)section{
return [carsNameArray count];
}
//每一行的 行高 (self.tableView.rowHeight = 80;)或者重写下面的方法
- (CGFloat)tableView:(UITableView*)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
return 60;
}
//行缩进
-(NSInteger)tableView:(UITableView *)tableViewindentationLevelForRowAtIndexPath:(NSIndexPath *)indexPath{
NSUInteger row =[indexPath row];
return row;
}
NSUInteger row
return row;
}
//行点击事件
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath*)indexPath{
NSLog(@"chick %ld line",(long)indexPath.row);
}
//判断选中的行
-(NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath*)indexPath
{
NSUIntegerrow =[indexPathrow];
if(row ==0)
return nil;
returnindexPath;
}
{
}
//划动cell是否出现del按钮
-(BOOL)tableView:(UITableView *)tableViewcanEditRowAtIndexPath:(NSIndexPath *)indexPath{
}
// 自定义划动时del按钮内容
}
//
-(NSString *)tableView:(UITableView *)tableView
titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath {
titleForDeleteConfirmati
}
//编辑状态
-(void)tableView:(UITableView *)tableViewcommitEditingStyle:(UITableViewCellEditingStyle)editingStyle
forRowAtIndexPath:(NSIndexPath *)indexPath
{
}
forRowAtIndexPath:(NSIndexPath
{
未完。
0 0
- ios - UITableViewController 笔记
- IOS学习笔记8—UITableViewController
- iOS UITableViewController
- 黑马程序员-IOS学习笔记-UITableView、UITableViewCell、UITableViewController
- iOS Programming 学习笔记 - 03 UITableView和UITableViewController
- iOS基础--UITableView,UITableViewController
- iOS编程------- UITableViewController
- IOS--UITableViewController及UITableView
- IOS基础-UITableViewController
- iOS之UITableViewController的使用
- iOS UITableViewController基本使用简述
- iOS - UITableViewController的RefreshControl使用
- ios开发 UITableViewController和 UITableView
- ios基于UITableViewController实现列表
- UITableViewController
- UITableViewController
- UITableViewController
- UITableViewController
- Linux下C基础编程----写在Blog之前的话
- java程序:一个排序好的数组,增加一个数插入到合适的位置保存到另外个数组,输出
- 经纬财富:鄂尔多斯套单形成的表现与解套技巧
- no-ip类似花生壳的动态IP
- c和c++的输入输出
- ios - UITableViewController 笔记
- AOSP Privileged vs System app
- Swap Nodes in Pairs
- asp.net identity
- HDU1506 Largest Rectangle in a Histogram (动规)
- HTML字符实体
- 多线程队列的算法优化 转载Parallel Labs
- 软件开发部门经理岗位职责
- (HDU 2680、HDU 1599、hdu2066,POJ 1125)n元最短路问题