UIButton remove all target-actions
Swift 2:
actionButton.removeTarget(nil, action: nil, forControlEvents: .AllEvents)
Swift 3 & 4:
actionButton.removeTarget(nil, action: nil, for: .allEvents)
Objective-C:
[actionButton removeTarget: nil action: NULL forControlEvents: UIControlEventAllEvents];
Swift 3, 4, 5:
btnCancel.removeTarget(nil, action: nil, forControlEvents: UIControlEvents.AllEvents)
Call removeTarget:action:forControlEvents:, pass nil for the target, NULL for action, and use a control mask that sets all bits (UIControlEventAllEvents).
Objective-C
[someControl removeTarget:nil
action:NULL
forControlEvents:UIControlEventAllEvents];
Swift 2
button.removeTarget(nil, action: nil, forControlEvents: .AllEvents)
Swift 3 or higher
button.removeTarget(nil, action: nil, for: .allEvents)
@progrmr's answer in Swift 2:
button.removeTarget(nil, action: nil, forControlEvents: .AllEvents)
and Swift 3:
button.removeTarget(nil, action: nil, for: .allEvents)
Note: Swift doesn't have NULL
, so I tested replacing it with nil
and it seems to work fine.