sterling archer
sterling archer

Reputation: 334

Swift / Xcode6: How to change when the UIButton functionality is called after clicking the button

I'm making an application that uses a stopwatch as part of the functionality. One of the components is a button that starts and stops the stopwatch. The button works fine, however the action is only completed once the button is tapped AND released. As of now, you could hold down the button and until you let go, nothing will happen to the timer. How can I change the functionality of the button so it performs the action on first touch as opposed to release? The functionality I'm seeking is that of touchesBegan.

Upvotes: 1

Views: 135

Answers (2)

Tim
Tim

Reputation: 2098

In the storyboard, open the connections inspector for your button, then drag a connection from Touch Down to your action code. Delete any other connections such as to Touch Up Inside.

Upvotes: 1

Joost
Joost

Reputation: 85

You need to select "Touch Down" in the "Send Events" section. enter image description here

Upvotes: 0

Related Questions