UITableView中的代理方法的含义以及它的基本属性
来源:互联网 发布:linux上新建weblogic域 编辑:程序博客网 时间:2024/06/07 06:38
VB
UITabelView 是iOS中用来以列表形式展开以及编辑信息的控件,集成自UIScrollView 所以能滑动,因为只有一列,所以只能在垂直方向滑动
UITabelView由分区section(班级内的分组)和分区内的行(分组内的人)组成.而且索引都是从零开始,要取到某一行,必须通过分区索引以及行索引,每一行的位置统一用一个NSIndexPath的类型的对象存储
UITabelView 的样式创建之后不可改变
属性有 datasource数据源,用来用tabelView提供数据
设置分割线的颜色 separatorColor
设置分割线样式 separatorStyle
设置分区索引的颜色 sectionIndexColor
设置tabelView页眉 tabelHeaderView
#pragma mark - UITableViewDataSource
//设置UITableView的分区个数
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return [self.stuDiccount];
}
//为tableView设置对应分区中的行数
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [_stuDic[_sortedKeys[section]]count];
}
//tableView的每一行都对应一个UItableViewCell对象
//针对于每一行返回一个UItableViewCell对象
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
//1.创建重用标识符
static NSString *identifier =@"acer";
//2.去重用队列(仓库)中根据重用标志符去取可重用的cell.
UITableViewCell *cell = [tableViewdequeueReusableCellWithIdentifier:identifier];
//3.判断重用队列中是否成功取到可重用的cell.
if (!cell) {
//cell 为空说明没有取到可重用的cell,就创建一个新的cell对象
cell = [[[UITableViewCellalloc] initWithStyle:UITableViewCellStyleValue1reuseIdentifier:identifier] autorelease];
NSLog(@"123");
}
//设置赋值视图的样式
cell.accessoryType =UITableViewCellAccessoryDetailDisclosureButton;
cell.textLabel.text =_stuDic[_sortedKeys [indexPath.section]][indexPath.row];
return cell;
}
//设置tableView分区的页眉title
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
return _sortedKeys[section];
}
//设置tableView分页的页脚title
//- (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section {
// return @"Duck";
//}
//设置tableView右边缘的分区索引
- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView {
return _sortedKeys;
}
#pragma mark - UITableViewDelegate
//当选中cell时触发
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSLog(@"section:%ld, row:%ld", (long)indexPath.section, (long)indexPath.row);
}
//取消选中时触发(前提是已经选中了一个cell)
- (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPathNS_AVAILABLE_IOS(3_0) {
NSLog(@"触发");
//indexPath 为取消选中的cell的位置
NSLog(@"deselect section:%ld, row:%ld", (long)indexPath.section, (long)indexPath.row);
}
//当点击cell上的辅助视图按钮时的触发
- (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath {
NSLog(@"hahahha");
}
//设置tableView每一行的高度,该方法在创建cell之前
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.row %2) {
return 50;
}
return 50;
}
//设置tableView分区页眉的高度
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
return 50;
}
//设置tableView分区页脚的高度
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
return 50;
}
- UITableView中的代理方法的含义以及它的基本属性
- UITableView的全部属性、方法以及代理方法执行顺序
- UITableView的全部属性、方法以及代理方法执行顺序
- UITableView的全部属性、方法以及代理方法
- UITableView的全部属性、方法以及代理方法执行顺序
- UItableView 属性,方法以及代理
- UI之UITableView的全部属性、方法以及代理方法执行顺序,常规的设置技巧
- Checklists学习日志之UITableView的全部属性、方法以及代理方法执行顺序
- UITableView的全部属性、方法以及代理方法执行顺序,PS--感谢分享者董鑫
- UItableview全部属性、方法以及代理方法执行顺序
- UITableView的常用代理方法
- UITableView的常用代理方法
- UITableView的常用代理方法
- UITableView的常用代理方法
- 属性以及它的特性
- UITableView的属性和方法
- UITableView Cell的属性方法
- UITableView的属性和方法
- 腾讯2013年实习生笔试题
- 使用R语言的BNLearn包实现贝叶斯网络
- Linux常用命令(三) - pwd
- UVA - 11401 Triangle Counting
- ostringstream及相关
- UITableView中的代理方法的含义以及它的基本属性
- R语言时间序列函数整理
- Linux下php+mysql+nginx编译搭建(二)
- 面试总结---chat room的UDP聊天室软件
- 使用API函数发送消息关闭程序:WM_CLOSE=0x0010;
- 机器学习的相关书籍推荐推荐
- 15款经典图表软件推荐 创建最漂亮的图表
- LeetCode OJ 之 Remove Nth Node From End of List ( 删除链表的从尾部数第n个结点 )
- 移动web开发框架研究