iOS ,UITableViewDataSource 和 UITableViewDelegate协议中常用方法
来源:互联网 发布:软件项目管理 pdf下载 编辑:程序博客网 时间:2024/04/30 02:27
UITableViewDataSource 协议中常用方法
1.设置右边 索引值
- ( NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView
2. 设置分组标识
- ( NSString *)tableView:( UITableView*)tableView titleForHeaderInSection:( NSInteger )section
3.
设置分组个数
- ( NSInteger )numberOfSectionsInTableView:(UITableView
*)tableView
4. 设置行数
- ( NSInteger )tableView:( UITableView*)tableView numberOfRowsInSection:( NSInteger )section
5. 创建
cell(使用重用机制,如下例)
- ( UITableViewCell *)tableView:( UITableView *)tableView cellForRowAtIndexPath:( NSIndexPath
*)indexPath
{
1.
创建重用标识符
static NSString *identifier =@"reuse”
;
2. 去重用队列中根据标识符取可重用的 cell
AddressBookCell *cell = [tableView dequeueReusableCellWithIdentifier :identifier];
3. 判断是否获取到可重用的 cell( 最后要空间释放)
if (!cell) {
cell = [[[ AddressBookCell alloc ] initWithStyle : UITableViewCellStyleDefaultreuseIdentifier :identifier] autorelease ];
}
return cell;
}
6. 设置 tableView 的每一行的编辑状态
(YES,可编辑)
- ( BOOL )tableView:( UITableView*)tableView canEditRowAtIndexPath:( NSIndexPath
*)indexPath
{
return YES
}
7.edit 按钮的点击事件 ( 当点击 edit 按钮时触发 )
- ( void )setEditing:( BOOL)editing animated:( BOOL )animated
8. 当提交编辑操作时触发
- ( void )tableView:( UITableView*)tableView commitEditingStyle:( UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:( NSIndexPath *)indexPath
9. 设置 tableView 每一行是否允许移动(YES,可移动)
- ( BOOL )tableView:( UITableView*)tableView canMoveRowAtIndexPath:( NSIndexPath *)indexPath
{
return YES
}
10. 提交移动操作之后触发
- ( void )tableView:( UITableView*)tableView moveRowAtIndexPath:( NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath *)destinationIndexPath
UITableViewDelegate协议中常用方法
1. 设置行高
- ( CGFloat )tableView:( UITableView*)tableView heightForRowAtIndexPath:( NSIndexPath *)indexPath
{
return 55;
}
2. 选中cell时触发
- ( void )tableView:( UITableView*)tableView didSelectRowAtIndexPath:( NSIndexPath *)indexPath
3. 设置 tableViewCell 的编辑样式 ( 插入 / 删除 )
- ( UITableViewCellEditingStyle )tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
4. 设置当点击编辑按钮时 上面显示的文字,如显示删除
- ( NSString *)tableView:( UITableView*)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:( NSIndexPath *)indexPath NS_AVAILABLE_IOS (3 _0) { return @" 删除" ; }
5. 设置 cell 移动的位置
- ( NSIndexPath *)tableView:( UITableView*)tableView targetIndexPathForMoveFromRowAtIndexPath:( NSIndexPath*)sourceIndexPath toProposedIndexPath:( NSIndexPath *)proposedDestinationIndexPath
- iOS ,UITableViewDataSource 和 UITableViewDelegate协议中常用方法
- iOS ,UITableViewDataSource 和 UITableViewDelegate协议中常用方法
- UITableViewDataSource 和 UITableViewDelegate协议中常用方法
- UITableViewDataSource和UITableViewDelegate内常用的13个方法
- iOS UITableViewDelegate UITableViewDataSource 执行顺序
- 在UITableView中iOS UITableViewDelegate UITableViewDataSource执行顺序
- iOS UITableViewDelegate UITableViewDataSource的含义 和执行顺序
- 如何将UITableViewDelegate和UITableViewDataSource从UITableViewController中分离出来?
- 如何将UITableViewDelegate和UITableViewDataSource从UITableViewController中分离出来?
- UITableViewDataSource, UITableViewDelegate
- UITableViewDataSource和UITableViewDelegate函数(一)
- UI之tableView的两个协议UITableViewDataSource、UITableViewDelegate
- iOS-将UITableViewDataSource协议和其他协议分离开
- 怎样创建表格---UITableView UITableViewDataSource UITableViewDelegate
- 怎样创建表格---UITableView UITableViewDataSource UITableViewDelegate .
- UITableViewDelegate方法
- UITableViewDelegate的代理方法
- UITableViewDataSource的方法
- UIButton的使用
- 利用javax.mail发送邮件
- 新的开始
- HDU 1695 GCD【莫比乌斯反演】
- linux进程通信--无名管道
- iOS ,UITableViewDataSource 和 UITableViewDelegate协议中常用方法
- 学生管理系统的心得
- c++第六次作业
- 如何安装pybrain?
- spark简介
- C++ operator关键字(重载操作符)
- 大学毕业4年-回顾和总结(10)-资金账务系统的架构设计(产品视角+技术视角)(图文并茂)
- 你不知道的input[type=search]
- 带你玩转Visual Studio——单元测试