滑动到删除不起作用 [英] Swipe to Delete not working

查看:91
本文介绍了滑动到删除不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的表格视图中的滑动删除功能不起作用。我已经在导航栏中实现了commitEditingStyle委托和Edit按钮。因此,当用户单击编辑按钮时,删除和添加按钮会正确显示。但是,在滑动时,删除按钮不会出现,似乎它无法将滑动识别为setEditing方法的调用。

The swipe to delete functionality is not working in my table view. I have implemented the commitEditingStyle delegate and the Edit button in the navigation bar. Hence when the user clicks the edit button, the delete and add buttons show up appropriately. However, on swiping, the delete button does not appear and it seems like it doesn't recognise the swipe as a call for the setEditing method.

然后我实现了willBeginEditingRowAtIndexPath和didEndEditingRwoAtIndexPath委托,如下所示:

I then implemented willBeginEditingRowAtIndexPath and didEndEditingRwoAtIndexPath delegates as follows:

-(void)tableView:(UITableView*)tableView willBeginEditingRowAtIndexPath:(NSIndexPath *)indexPath

{
 NSLog(@"WILL BEGIN EDITING");

 [self.tableView setEditing:YES animated:YES];

}


-(void)tableView:(UITableView*)tableView didEndEditingRowAtIndexPath:(NSIndexPath *)indexPath

{

[self.tableView setEditing:NO animated:YES];

}

然而这也没有任何影响。可能的问题是什么?我已经为IB中的表格视图启用了多点触控,每个单元格都有一个DetailDisclosureButton附件。

However this does not have any effect either. What could be the possible issue? I have enabled multi-touch for the table view in the IB and each cell has an DetailDisclosureButton accessory.

推荐答案

对于滑动到删除功能,您必须实现

For swipe-to-delete functionality, you have to implement

 -(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (editingStyle == UITableViewCellEditingStyleDelete)
        ; // Delete.
}

编辑:我没有看过这个问题够了。

I didn't read the question well enough.

我注意到要在模拟器中进行滑动拖动我必须按住并暂停一秒钟,同时选择单元格,只有这样我才可以向右滑动成功。

I have noticed that to do a swipe drag in the simulator I have to press and pause for a second while it selects the cell, and only then can I swipe right successfully.

这篇关于滑动到删除不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆