我试过了,但刷卡不会触发 tableView:willBeginEditingRowAtIndexPath: !并且删除按钮永远不会出现,是否有解决方法?
编辑:这是我的实现
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
return YES;
}
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
return YES;
}
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
{
return UITableViewCellEditingStyleDelete;
}
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
[tableView beginUpdates];
if (editingStyle == UITableViewCellEditingStyleDelete)
{
if(_itemsArray == nil)
NSLog(@"\n\nNIL ARRAY\n\n");
NSLog(@"\nindexPath.row = %d\nItemsArray Count:%d",indexPath.row,_itemsArray.count);
int row = [[[_itemsArray objectAtIndex:indexPath.row]valueForKey:@"itemRow"] integerValue];
[_itemsArray removeObjectAtIndex:indexPath.row];
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
[[self delegate]didDeletedBillItemRow:row];
}
[tableView endUpdates];
}