在让tableview可编辑时,添加实现下面3个delegate方法:spa
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath{it
return YES;table
}方法
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath{im
return UITableViewCellEditingStyleDelete;margin
}word
// 添加这个方法后能够滑动cell,显示delete, ps: editingStyleForRowAtIndexPath 为 UITableViewCellEditingStyleInsert 的时候滑动无效, 须要自行添加[tbView_roster setEditing:YES animated:YES]; 例以下面在 didSelectRowAtIndexPath 中添加 setEditing:animated:tab
- (void) tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath{animate
// do sth...di
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
[tbView_roster setEditing:YES animated:YES];
}