编辑UI表视图,在刷卡和按钮显示之间调用

时间:2014-11-24 14:33:41

标签: ios objective-c

在显示删除按钮之前向左滑动UITableViewCell时,我可以在哪里调用方法?

- (void)tableView:(UITableView *)tableView commitEditingStyle:    (UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
    if (editingStyle == UITableViewCellEditingStyleDelete) {

        //DELETE IS TAPPED


    }
}

2 个答案:

答案 0 :(得分:0)

滑动手势应该有效。

- (void)viewDidLoad
{
    UISwipeGestureRecognizer *recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self
                                                                              action:@selector(swipeLeft:)];
    [recognizer setDirection:(UISwipeGestureRecognizerDirectionLeft)];
    [self.tableView addGestureRecognizer:recognizer];
}

- (void)swipeLeft:(UISwipeGestureRecognizer *)gestureRecognizer
{
    CGPoint location = [gestureRecognizer locationInView:self.tableView];
    NSIndexPath *indexPath = [self.tableView indexPathForRowAtPoint:location];

    // Do whatever you need to do to the cell.

}

答案 1 :(得分:0)

啊,找到了办法。如果其他人都很好奇,这似乎就在显示删除按钮之前完成了 -

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