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

查看:23
本文介绍了当 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 上或离开 UIView 时获得通知(请参阅 UIAccessibilityFocus 协议).

您想让部分 UI 不受 VoiceOver 手势的影响(VoiceOver 不会处理(窃取")此区域中的手势),以便您可以自己检测手势(包括单指向左滑动/right) 以标准方式并以您想要的方式处理它们.然后,您必须将 UIAccessibilityTraitAllowsDirectInteraction trait 添加到相关 UIViewaccessibilityTraits 属性(请参阅 UIAccessibility 协议 了解更多详情).使用此功能的一个突出示例是 iOS 版 GarageBand - 钢琴键盘或鼓具有此特性,因此 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天全站免登陆