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.
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
.
You need to select "Touch Down" in the "Send Events" section.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.