滑动UITableview的删除行问题

时间:2012-07-11 06:47:51

标签: ipad uitableview ios-simulator

这会让我发疯!很多类似的问题,但我似乎仍然无法弄清楚为什么我的刷卡删除代码不起作用! “删除”按钮不会出现。在UITableview单元格中,在模拟器中,与设备相比,是否有一些特殊的滑动方式? 这是代码,

- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath

{

return YES;
}


-(UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
{
return UITableViewCellEditingStyleDelete;
}



-(void) setEditing:(BOOL)editing animated:(BOOL)animated
{
  [super setEditing:editing animated:animated];

[self.tableView setEditing:editing animated:animated];
}




// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
   if (editingStyle == UITableViewCellEditingStyleDelete) 
{
    [attachmentsArray removeObjectAtIndex:indexPath.row];
    [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath]     withRowAnimation:UITableViewRowAnimationLeft];
    [tableView reloadData];
}   

}

{ return YES; } -(UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath { return UITableViewCellEditingStyleDelete; } -(void) setEditing:(BOOL)editing animated:(BOOL)animated { [super setEditing:editing animated:animated]; [self.tableView setEditing:editing animated:animated]; } // Override to support editing the table view. - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { if (editingStyle == UITableViewCellEditingStyleDelete) { [attachmentsArray removeObjectAtIndex:indexPath.row]; [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationLeft]; [tableView reloadData]; } }

更新 - 在处放置断点,但控件永远不会转到commitEditingStyle。它只是在前两个之间循环。

0 个答案:

没有答案