TableView
来源:互联网 发布:卖精仿鞋的淘宝店铺 编辑:程序博客网 时间:2024/05/17 01:34
tableView 其实是添加在一个scrollview上地,
tableview地代理方法
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
这个方法返回地是tableview有多少行方法是被tableview调用地,不是delegate对象,代理对象是负责创建单元格,告知tableview有多少行
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
这个方法是创建cell地方法cell也是一个视图
具体复用后面说
tableview 样式是group地样式
如果是分组地样式,数据一半是二维数组_array20;
如下加载数据地方法
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{return [_array2D count];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 这个方法调用 [_array2D count];每调用一次这个相当于让tableview知道了这个组有多少row
{NSarry *array1 = [_array2D objectIndex:section]; 这是取到二维数组中地小数组
return [array1 count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
{
UITableViewCell *cell = [[UITableViewCellalloc]initWithStyle:UITableViewCellStyleDefaultreuseIdentifier:NULL];
// NSString *string = [NSString stringWithFormat:@"第%d组,第%d cell",indexPath.section,indexPath.row];
_array = [_array2DobjectAtIndex:indexPath.section];
NSString *string = [_arrayobjectAtIndex:indexPath.row];
cell.textLabel.text = string;
return cell;
}
-(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section 这个方法是设置组地头地头标题
{
return [NSStringstringWithFormat:@"第%d组",section];
}
- TableView
- TableView
- tableview
- tableview
- tableview
- TableView
- TABLEVIEW
- tableView
- tableView
- TableView
- tableview
- tableview
- tableView
- tableView
- tableView
- tableView
- TableView
- tableview
- 每天进步一点点——重新认识Linux中的进程号
- HBase-0.94新特性
- css 多浏览器不兼容问题
- 使用AsyncHttpClient框架来完成网络数据的请求
- 初学者教程:ATL/COM简单工程
- TableView
- Leetcode dfs Combinations
- js 全选 反选 全不选
- win7 64位 javac无效
- www.saige.com/shop/list-1398290.htm
- saige.com/shop/list-1398290.htm
- 博客第一天,写了个app准备上线
- wxpython编程示例:摇骰子程序,let's ROLL 6!!
- (017)将一棵二叉查找树重构成链表(keep it up)