Iphone 滑动以删除不工作的内容

Iphone 滑动以删除不工作的内容,iphone,uitableview,uiview,ios4,Iphone,Uitableview,Uiview,Ios4,“滑动以删除”功能在“我的表”视图中不起作用。我已经实现了CommittedItingStyle委托和导航栏中的编辑按钮。因此,当用户单击编辑按钮时,删除和添加按钮会相应地显示出来。但是,在刷卡时,删除按钮不会出现,并且似乎无法将刷卡识别为对setEditing方法的调用 然后,我实现了willBeginEditingRowAtIndexPath和DiEndEditingRowatindexpath委托,如下所示: -(void)tableView:(UITableView*)tableView

“滑动以删除”功能在“我的表”视图中不起作用。我已经实现了CommittedItingStyle委托和导航栏中的编辑按钮。因此,当用户单击编辑按钮时,删除和添加按钮会相应地显示出来。但是,在刷卡时,删除按钮不会出现,并且似乎无法将刷卡识别为对setEditing方法的调用

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

-(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中为表格视图启用了多点触摸,每个单元格都有一个DetailDisclosure按钮附件

要使用刷卡删除功能,您必须实现

 -(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (editingStyle == UITableViewCellEditingStyleDelete)
        ; // Delete.
}
编辑:我对这个问题读得不够好


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

您是否实现了
表格视图:editingStyleForRowAtIndexPath:
方法并使其返回
UITableViewCellEditingStyleDelete
我在表格视图中执行了以下操作:editingStyleForRowAtIndexPath:委派方法:-

if (self.editing == NO || !indexPath)
{   
    return UITableViewCellEditingStyleNone;
}
如果未选择indexPath,则应返回编辑样式none。由于某种原因,每当执行刷卡操作时,都会执行此特定的if条件。在对上述代码段进行注释时,滑动到删除操作效果良好


谢谢大家的帮助。

您需要实施:

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath;


- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath;

- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath;
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath;

有了这三样东西,你就可以走了。(我错过了CommittedItingStyle,它从来没有起过作用。

让它起作用的关键是实施:

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath;


- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath;

- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath;
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath;

请记住将它放在“UITableViewDataSource”中,而不是“UITableViewDelegate

-(void)tableView:(UITableView*))tableView提交的编辑样式:(UITableViewCellEditingStyle)rowAtIndexPath的编辑样式:(nsIndepath*)indexPath
委托方法还需要实现工作刷卡功能。

如果所有其他建议都没有帮助,请尝试检查代码中是否有平移手势识别器。如果在某些底层视图中有类似的内容,则无法工作。

是的,我已经实现了。我在上面提到过。我没有访问设备的权限ce现在正在模拟器上测试。这可能是模拟器的问题吗?你也是。抱歉。请检查我编辑的答案以防万一。模拟器不是1-1触控行为,尤其是速度。在模拟器上尝试过。不起作用。还将应用程序安装在运行3.1.2的iPod touch上。在该情况下,滑动以删除也不起作用。Ve我很困惑。我想知道我是否错过了一些委托实现?事情是这样的。我开始了一个新项目,一个UITableViewController只实现了CommittedItingStyle委托,滑动删除功能工作得很好。需要看看我的代码中有什么阻碍了我在其他项目中的工作。是的是的。但其中有一些额外的东西导致了这个问题。很高兴我能让您看到正确的代码段。调试这样的问题通常很困难。我给出了这3个委托方法,但不起作用。有同样的问题,但是UIAPTgesture。您是个天才!我有一个很难拖动的滑块问题几个月后,现在有了tableviewCell,问题是我使用的框架中的平移手势识别器。