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

135 views Asked by At

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.

2

There are 2 answers

2
Tim On BEST ANSWER

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.

0
Joost On

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