or is there a way to check whether a UIControl has any UIActions?
Sometimes I want to change a UIControl’s behavior.
When using target-action, I can do it like this
button.removeTarget(nil, action: nil), for: .touchUpInside)
button.addTarget(self, action: #selector(didTouchUpInside()), for: .for: .touchUpInside)
3
Answers
Why not you are using
view.isUserInteractionEnabled = false
? It will remove all the interaction ability of a viewYou can do this using
enumerateEventHandlers
:Taking what jrturton has said here, you can turn it into a small extension:
And now you can just call
removeAllActions()
on your UIButton to have the same effect.