IOS hardware volume buttons - press and hold

Well, there are many questions about using the iphone hardware volume buttons for your own purposes (such as camera shutter); All that I saw is based on receiving notification of a change in volume.

I need to distinguish the volume button from the hold / release. Of course, it can be implemented on the basis of On volume change event, if there another event coming shortly - that a hold (or quick double press); if no event is coming within eg half a second that a button press. notifications, for example: On volume change event, if there another event coming shortly - that a hold (or quick double press); if no event is coming within eg half a second that a button press. On volume change event, if there another event coming shortly - that a hold (or quick double press); if no event is coming within eg half a second that a button press.

But. There the application is called Snapchat; they use a press of the volume button to take a picture, and a volume button to record video while holding. And this application perfectly informs that the press is held by pressing - which means that the press event is recognized immediately, and not after half a second.

So the question is, how do they do it?

+5
source share

Source: https://habr.com/ru/post/1242498/


All Articles