简体   繁体   中英

Swift: Volume button long press and release

I am working on a camera app that requires that whenever a volume button is long pressed, it should take a burst shot just like in the native iPhone camera app. I am unable to get the event of a long press. Any kind of help would be appreciated how can I get the long press event of the volume button.

I believe there is no available API for this event. You can only detect volume change by observing outputVolume or with a SystemVolumeDidChange notification (private API).

The behaviour you are describing that can be find in the system Camera app is something only apple can do with their private APIs.

Edit: Your best bet would be to monitor the frequency of volume change events and based on that you could trigger the "burst" that lasts as long as the events are coming.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM