-(BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath*)indexPath
{
//打开编辑
return YES;
}
- (void)setEditing:(BOOL)eanimated:(BOOL)ani
{
[super setEditing:eanimated:ani];
[mSpecialTableViewsetEditing:e animated:ani];//tableView设置
if (e)self.editButtonItem.title =_(@"done");
elseself.editButtonItem.title =_(@"edit");
}
//tableView 中cell选中事件
- (void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:(NSIndexPath*)indexPath
{
NSInteger specialIndex = [[TQDownListshareInstance]getCurSepcailIndex:indexPath.row];
NSString *strKey = [[TQDownListshareInstance]getCurRowIndex:specialIndex];
TQDownViewSecondPage *taskPage =[[TQDownViewSecondPage alloc]init];
[taskPage setSpecialKey:strKey];
[self.navigationControllerpushViewController:taskPageanimated:YES];
[taskPage release];
}
//编辑tableView 时调整cell view里的控件位置
- (void)layoutSubviews
{
#define REDUCE_LEN 59
int tag = 25;
if(self.editing)
{
//编辑时的位置
} else
{
//默认位置
}
[superlayoutSubviews];
}
四、允许cell之间的拖动
- (BOOL)tableView:(UITableView*)tableView canMoveRowAtIndexPath:(NSIndexPath*)indexPath
{
//允许移动
return YES;
//return NO;
}
- (void)tableView:(UITableView*)tableView moveRowAtIndexPath:(NSIndexPath*)sourceIndexPath toIndexPath:(NSIndexPath*)destinationIndexPath
{
//交换数据
}
本文介绍了如何在iOS应用中实现UITableView的编辑功能,包括删除单元格、调整单元格内控件的位置以及允许用户拖动单元格来重新排序。通过具体的代码示例展示了如何开启编辑模式、响应单元格选择事件及实现单元格的移动。
5465

被折叠的 条评论
为什么被折叠?



