简体   繁体   English

Swift:音量键长按松开

[英]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.我正在开发一个相机应用程序,它要求每当长按音量按钮时,它应该像在本机 iPhone 相机应用程序中一样连拍。 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.我相信此事件没有可用的 API。 You can only detect volume change by observing outputVolume or with a SystemVolumeDidChange notification (private API).您只能通过观察outputVolume或使用SystemVolumeDidChange通知(私有 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.您所描述的可以在系统相机应用程序中找到的行为是只有苹果可以使用其私有 API 执行的操作。

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.编辑:您最好的选择是监控音量变化事件的频率,并基于此您可以触发只要事件发生就会持续的“爆发”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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