Disable a table row when deleting?

I have a table that contains two buttons per row/cell. I implemented swipe left to delete but the problem I have is, when the swipe is initiated from one of the buttons a button-press is sent and rather than being able to delete the row the button action is fired. I'm trying to come up with a way to prevent this (disable button, disable button action, etc) but nothing works because the timing of the event is such that, as soon as you raise your finger to tap the delete button the action is run. Does anyone have an idea how I could fix this?


This is a truncated version of my working code to give an idea of what is going on...


// BUTTON ACTION
@IBAction func button1(sender: AnyObject) {
      
     // Do stuff based on which button was pressed
     // This is what needs to NOT run when trying to delete a row in teh table
        buttonFunction(sender.tag, optionId: 1)
    }


// DELETE ROW
override func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
     
        if editingStyle == UITableViewCellEditingStyle.Delete {
            tableView.beginUpdates()
         
            // remove values from array, etc...

            tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: UITableViewRowAnimation.Automatic)
            tableView.endUpdates()
        }


// Build table rows
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
       
        var cell = TheirQuestionsCell()/
        if contains(self.dismissed, questionIds[indexPath.row]) == true {
           
            //
            cell = tableView.dequeueReusableCellWithIdentifier("cell2", forIndexPath: indexPath) as! TheirCell
           
            //
            cell.selectionStyle = UITableViewCellSelectionStyle.None
           
            // Do some formatting
        } else {
           
            //
            cell = tableView.dequeueReusableCellWithIdentifier("cell1", forIndexPath: indexPath) as! TheirQuestionsCell
           
            //
            cell.selectionStyle = UITableViewCellSelectionStyle.None
           
            // Do some other formatting
            
            // tag the buttons that need to be disabled when deleting row
            cell.option1.tag = indexPath.row
            cell.option2.tag = indexPath.row
        }
       
        return cell
    }

This might not be the cleanest way to do it, but would something like this work?


Adding:

var isCurrentlyEditing: Bool = false
func tableView(tableView: UITableView, willBeginEditingRowAtIndexPath indexPath: NSIndexPath)
{
    isCurrentlyEditing = true
}
func tableView(tableView: UITableView, didEndEditingRowAtIndexPath indexPath: NSIndexPath)
{
    isCurrentlyEditing = false
}


Update:

// BUTTON ACTION
@IBAction func button1(sender: AnyObject) {
   
    // Do stuff based on which button was pressed
    // This is what needs to NOT run when trying to delete a row in the table
    if (!isCurrentlyEditing) {buttonFunction(sender.tag, optionId: 1)}
}

Or, if the buttons are automatically disabled when the row is swiped,


// BUTTON ACTION
@IBAction func button1(sender: AnyObject) {
   
    // Do stuff based on which button was pressed
    // This is what needs to NOT run when trying to delete a row in the table
    if let button = sender as? UIControl where button.enabled {buttonFunction(button.tag, optionId: 1)}
}

Disable the button as soon as swiping starts:


override func willTransition(to state: UITableViewCellStateMask) {
     super.willTransition(to: state)    
     theButton.isEnabled = !state.contains(.showingDeleteConfirmationMask)
}
Disable a table row when deleting?
 
 
Q