如何通过iOS接收并按住“远程控制事件"? [英] How to receive single tap and hold Remote-Control Event with iOS?

查看:73
本文介绍了如何通过iOS接收并按住“远程控制事件"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找我的应用程序,以监听iOS设备的耳机上的播放/暂停"按钮.当前,其行为是启动语音控制(在我的iPhone 4上).

I'm looking for my app to listen for the single tap and hold of the play/pause button on headphones for iOS devices. Currently, the behavior is to start Voice Control (on my iPhone 4).

远程控制事件允许双击(BeginSeekingForward)和释放(EndSeekingForward),但我正在寻找当前激活语音控制的单击并按住.

The event list for remote control events allows for getting the double tap and hold (BeginSeekingForward) and the release (EndSeekingForward), but I'm looking for the single tap and hold which currently activates Voice Control.

我的应用是否可以覆盖语音控制并监听并按住一次?

Is there a way for my app to override Voice Control and listen for the single tap and hold?

推荐答案

您可以将UILongPressGestureRecognizer添加到UIButton中,然后从那里开始工作.

You can add in a UILongPressGestureRecognizer to your UIButton and work from there.

如果要防止调用其他方法,则还需要一个UITapGestureRecognizer,该工具会统计点击次数,并在收到第二次点击和另一个方法(通过UIResponder touch *方法检查)时将其值设置为true.触摸释放,然后将值设置回false.

If you want to prevent your other method from being called, you'll also need a UITapGestureRecognizer that counts taps and sets a value to true when it receives a second tap and another method (Check from your UIResponder touch* methods) for a touch release and set the value back to false.

使用该值,您可以与UILongPressGestureRecognizer进行检查,以查看用户是否两次轻按.

Using that value, you can check with the UILongPressGestureRecognizer to see if the user double tapped or not.

或者,您也可以将触摸次数不为2的按钮设置为false.

希望这会有所帮助!

据我所知,如果不越狱设备,您将无法覆盖耳机.通常,您永远不必为使用Apple耳机进行交互的人员编写代码,因为那样会严重减少应用程序的市场和可用性.例如,如果有人忘记了耳机,他们将无法使用您的应用程序.这只是要考虑的事情.您不想过多限制应用程序的可访问性.

You cannot override the headphones (as far as I know) without jailbreaking the device. Normally you should never have to code for people interacting using the Apple headphones, since that would severely reduce the market and usability of your app. If someone were to forget their headphones, for example, they could not utilize your app. Its just something to think about. You don't want to limit your apps accessibility too much.

这篇关于如何通过iOS接收并按住“远程控制事件"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆