当VoiceOver打开时,应用程序是否可以检测到单指(左右)滑动? [英] when VoiceOver is on, is there a way an app can detect a single-finger (left-right)swipe?

查看:151
本文介绍了当VoiceOver打开时,应用程序是否可以检测到单指(左右)滑动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当VoiceOver在iOS设备上处于活动状态时,单指滑动(左或右)手势允许用户浏览视图中的不同元素。有没有办法检测用户在使用画外音时是否使用了单指滑动手势?

When VoiceOver is active on an iOS device, the single-finger swipe(left or right) gesture allows users to browse the different elements in the view. Is there a way to detect if a user used the single-finger swipe gesture when using voiceover?

推荐答案

您可能会问以下两种情况之一:

You might be asking either of 2 things:


  1. 您想知道VoiceOver用户何时成功向VoiceOver发出单指滑动左/右手势 - VoiceOver将从您的代码中处理(窃取)手势并执行其操作(移动) VoiceOver光标到下一个/上一个元素)。您可以获得的最接近的是当VoiceOver光标落在或离开时获取UIView的通知(请参阅 UIAccessibilityFocus协议)。

您希望将UI的一部分作为主题到VoiceOver手势(VoiceOver不会在此区域处理(窃取)手势),以便您可以自己检测手势(包括单指左/右滑动)并以您想要的方式处理它们你的应用。然后,您必须将 UIAccessibilityTraitAllowsDirectInteraction 特征添加到 accessibilityTraits 属性到相关的 UIView (参见 UIAccessibility protocol 了解更多详情)。使用它的一个突出例子是在GarageBand for iOS中 - 钢琴键盘或鼓具有这种特性,因此VoiceOver用户可以在不关闭VoiceOver的情况下在乐器上演奏。

You want to make part of your UI not subject to VoiceOver gestures (VoiceOver will not process ("steal") gestures in this area) so that you can detect the gestures yourself (including the single-finger swipe left/right) in a standard way and process them in the way you want for your app. Then you must add the UIAccessibilityTraitAllowsDirectInteraction trait to the accessibilityTraits property to the relevant UIView (see UIAccessibility protocol for more details). A prominent example of where this is used is in GarageBand for iOS - the piano keyboard or drums have this trait so that VoiceOver user can play on the instruments without turning VoiceOver off.

这篇关于当VoiceOver打开时,应用程序是否可以检测到单指(左右)滑动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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