UITableViewDataSource
2015-08-26 08:46
393 查看
UITableViewDataSource
关于UITableView的一些相关的属性和方法,以及一些代理方法的使用.
说到UItableView的一个代理是:UITableViewDataSource返回cell的数量
- (NSInteger)numberOfSectionsInTableView:(UITableView *
nonnull)
在section里现在的row的序号
显示右边的导航标题- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView当点击右边的标题的时候,就可以直接的跳转到指定的title处,不论你点的是什么,直接跳转返回值处
- (NSInteger)tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString
*)title atIndex:(NSInteger)index根据section来设置titleHeader- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section根据section来设置titleFooter- (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section根据点击的编辑按钮,来执行相应的处理- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle
forRowAtIndexPath:(NSIndexPath *)indexPath
在可以编辑之前必须要把tableView的setEditing设置成YES.
代码如下:[tableView
setEditing:YES];
在代理方法里判断editingStyle来执行相对应的处理.可以根据indexPath来设置是否可以被编辑- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath
*)indexPath是否可以移动cell,可以根据indexPath来判断- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath
*)indexPath
但是,要与下面的方法结合使用:- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath
*)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath
在移动的时候,要注以的是,数据先行,视图后行.
关于UITableView的一些相关的属性和方法,以及一些代理方法的使用.
说到UItableView的一个代理是:UITableViewDataSource返回cell的数量
- (NSInteger)numberOfSectionsInTableView:(UITableView *
nonnull)
tableView
知道现在的cell是哪一个.即得到当前的cell的标签,然后通过标签来做其他的事情
- (UITableViewCell * nonnull)tableView:(UITableView * nonnull)[/code]tableViewcellForRowAtIndexPath:(NSIndexPath *
nonnull)[code]indexPath
在section里现在的row的序号
- (NSInteger)tableView:(UITableView * nonnull)tableViewnumberOfRowsInSection:(NSInteger)
section[/code]
显示右边的导航标题- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView当点击右边的标题的时候,就可以直接的跳转到指定的title处,不论你点的是什么,直接跳转返回值处
- (NSInteger)tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString
*)title atIndex:(NSInteger)index根据section来设置titleHeader- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section根据section来设置titleFooter- (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section根据点击的编辑按钮,来执行相应的处理- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle
forRowAtIndexPath:(NSIndexPath *)indexPath
在可以编辑之前必须要把tableView的setEditing设置成YES.
代码如下:[tableView
setEditing:YES];
在代理方法里判断editingStyle来执行相对应的处理.可以根据indexPath来设置是否可以被编辑- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath
*)indexPath是否可以移动cell,可以根据indexPath来判断- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath
*)indexPath
但是,要与下面的方法结合使用:- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath
*)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath
在移动的时候,要注以的是,数据先行,视图后行.
相关文章推荐
- mui
- POJ-1019-Number Sequence-组合数学
- UI中的网页加载
- hdu5412--CRB and Queries(整体二分)
- UI初级第八课  定制单元格——iOS学习连载23
- UI初级第七课  表视图的使用——iOS学习连载22
- UI:基础
- HDU 1005 Number Sequence
- RPG黑暗之光(5)NGUI实现背包系统初步
- RPG黑暗之光(4)添加第一个NPC、NGUI实现任务发布
- UIDatePicker 使用方法
- 解决git clone时报错:The requested URL returned error: 401 Unauthorized while accessing
- Reveal UI 分析工具简单使用
- Android UI设计之Color搭配
- 【POJ1417】【True Liars】【加权并查集+背包+输出路径】
- UIBarbuttonItem中UIBarbuttonsystemItem的用法
- queue的入门
- UIImagePickerController
- 【leetcode】Distinct Subsequences
- requireJS的使用_API-1