nigelhs
nigelhs

Reputation: 71

How to get event from IBAction method

I've connected a UITextField to an action method for a number of events. To enable me to check what the specific event was I used the sender: event: method type. However, I am now at a loss as to how to determine what the actual event that triggered the method was. What's the secret?

Upvotes: 2

Views: 990

Answers (1)

Rob Napier
Rob Napier

Reputation: 299485

The "event" is the one passed to your action method, but I assume your real question is which of the UIControlEvents caused the action. UIEvent and UIControlEvents are unrelated. The target/action pattern provides a UIEvent. If you want to handle different UIControlEvents differently, you should implement different actions for them.

Remember, the target/action mechanism comes from UIResponder. UIControlEvents are related to UIControl.

Upvotes: 1

Related Questions