UITableView的删除,移动及修改删除按钮上的文字
来源:互联网 发布:mac中英文切换快捷键 编辑:程序博客网 时间:2024/06/08 01:10
其实修改UITableView进行删除操作的时候右边出现的删除按钮上的文字很简单:
重写delegate方法:-(NSString*)tableView:(UITableView*)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath*)indexpath;
如果需要出现UITableView上滑动cell时出现删除按钮的话,需要进行一下操作:
首先设置你的UITableViewCell的EditingStyle是UITableViewCellEditingStyleDelete,这个时候有多种方法,
一是创建cell的时候直接设置,
二是在tableview的delegate中设置,delegate方法如下:
-(UITableViewCellEditingStyle)tableView:(UITableView*)tableView editingStyleForRowAtIndexPath:(NSIndexPath*)indexPath;
针对响应的indexpath返回UITableViewCellEditingStyleDelete。
三是你不要尝试自己设置cell的editingStyle属性也不要重载方法二中的方法,这样默认状态下cell的editingStyle值即为UITableViewCellEditingStyleDelete。
其次是最关键的,你一定要重载uitableview的这个delegate方法,否则是无法滑动弹出删除按钮的,
-(void)tableView:(UITableView*)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath*)indexPath;
原因想想应该也简单,如果没有这个函数你根本就无法找到触发点击那个弹出删除按钮后的方法。
如果会对按钮的出现和消失的时刻感兴趣,那么此刻要实现代理的方法(下面的2 3):
(1)- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingSt
(2)- (void)tableView:(UITableView *)tableView willBeginEditingRowAtInd
(3)- (void)tableView:(UITableView *)tableView didEndEditingRowAtIndexP
而UITableView编辑时如何能移动UITableViewCell也简单,即实现UITableView的moveRow这个方法:
-(void)tableView:(UITableView*)tableView moveRowAtIndexPath:(NSIndexPath*)indexPath toIIndexPath:(NSIndexPath*)indexPath;
这样当你设置UITableView的editing为YES的时候就会出现移动cell的那种按钮了。
=========================================
附带内容:
关于group的UITableView的section跳转时,实现下面方法可以重新定位点击哪个section来跳转到哪个section
-(void)tableView:(UITableView*)tableView sectionForSectionIndexTitle:(NSString*)title atIndex:(NSInteger*)index;
- UITableView的删除,移动及修改删除按钮上的文字
- ITableView的删除,移动及修改删除按钮上的文字,来自,dick_china
- UITableView的移动、删除操作
- 修改/删除导航栏返回按钮的文字
- UITableView实现删除移动编辑的样式
- ios UITableView的移动、添加和删除
- UITableView 的行删除
- UITableView 左右滑动时,出现删除按钮的动画。
- UITableView 左右滑动时,出现删除按钮的动画。
- UITableView 左右滑动时,出现删除按钮的动画
- 给UITableView的侧滑删除增加多个按钮
- UITableView的编辑操作(移动&添加&删除-单选删除,或多选删除)
- UITableView项目中行的操作 (添加移动和删除)
- UITableView项目中行的操作 (添加移动和删除)
- 删除实体主页上的‘新建’按钮
- MFC删除工具栏上的关闭按钮
- 自定义UITableViewCell上的删除按钮
- 窗口上的【增加】【修改】【删除】【查询】【刷新】【查看】【退出】按钮的实现方法
- “光驱不见了”的解决方法
- 和菜鸟一起学linux总线驱动之初识spi驱动数据传输流程
- 多线程高级编程
- S5PV210 Android 创建的video设备
- Qt4.7中文显示设置
- UITableView的删除,移动及修改删除按钮上的文字
- 使用python偷偷发邮件
- MFC中用户界面元素更新原理
- linux下线程的同步
- C#入门————Hello World
- MFC项目Unicode版本程序入口
- 为什么局部内部类访问局部变量,局部变量必须声明为final?
- java反射机制
- C#带TreeView 选中复选框里的集合