当我将UITableView放入编辑模式时,我一直试图阻止(-) delete指示器出现。
为清晰起见更新:
这张表是这样的:
这是我在- (NSArray *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath中设置的
当我点击重新排序,我进入编辑模式。我不想让这些东西显示:
我已经通过限制从editActionsForRowAtIndexPath显示的按钮来删除第三个屏幕截图,但我甚至不想进入这个部分。我只希望编辑模式被重新排序。
/Updates
我尝试过设置UITableViewCell.shouldIndentWhileEditing = NO
直接在该小组:
cell.indentationLevel = -3;
cell.shouldIndentWhileEditing = NO;
在接口生成器中
在适当的委托方法中
- (BOOL)tableView:(UITableView *)tableview shouldIndentWhileEditingRowAtIndexPath:(NSIndexPath *)indexPath
NSLog(@"shouldIndentWhileEditingRowAtIndexPath");
return NO;
}
我还显示了操作列表中的项目。在编辑模式下,我根本没有打算删除,只是重新浏览。我调整了一些东西,所以我只在用户滑动时显示删除,但我宁愿(-)根本不显示:
- (void) endEditing
self.editMode = NO;
self.editControlButton.title = @"Reorder";
[self setEditing:NO animated:YES];
//[self.tableView reloadData];
- (void) startEditing
self.editMode = YES;
self.editControlButton.title = @"Done";
[self.tableView setEditing:YES animated:YES];
#pragma - mark UITableViewDelegate
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
return YES;
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
return UITableViewCellEditingStyleDelete;
- (BOOL)tableView:(UITableView *)tableview shouldIndentWhileEditingRowAtIndexPath:(NSIndexPath *)indexPath
NSLog(@"shouldIndentWhileEditingRowAtIndexPath");
return NO;
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
TCORead *item = [self.fetchedResultsControllerDataSource selectedItem];
manager.currentRead = item;
- (NSArray *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewRowAction *deleteAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:@"Delete" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath){
[self.tableView setEditing:NO];
//workaround, rdar://17969970
//normally don't want to be able to get into this menu when reordering
if (!self.editMode) {
UITableViewRowAction *shareAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleNormal title:@"Share" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath){
[self.tableView setEditing:NO];
shareAction.backgroundColor = [UIColor grayColor];
UITableViewRowAction *doneAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:@"Done" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath){
[self.tableView setEditing:NO];
doneAction.backgroundColor = [UIColor greenColor];
[self startEditing];
return @[deleteAction, doneAction, shareAction];
return @[deleteAction];
- (void)tableView:(UITableView *)tableView didEndEditingRowAtIndexPath:(NSIndexPath *)indexPath
[self endEditing];
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
//empty on purpose
}
发布于 2014-09-11 11:56:26
我强迫删除指示符出现。 范尼亚斯 有一个示例项目,它向我展示了我做错了什么。
我的editingStyleForRowAtIndexPath方法需要如下所示:
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath: (NSIndexPath *)indexPath