知道现在的cell是哪一个.即得到当前的cell的标签,然后通过标签来做其他的事情
- (UITableViewCell * nonnull)tableView:(UITableView * nonnull)tableView
cellForRowAtIndexPath:(NSIndexPath * nonnull)indexPath
- (NSInteger)tableView:(UITableView * nonnull)tableView
numberOfRowsInSection:(NSInteger)section
- (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
在移动的时候,要注以的是,数据先行,视图后行.