是否有某种UIAccessibility警报音调?

时间:2022-11-25 16:53:54

Is there any way to get iOS to play the tone that UIActionSheet plays when presented? It’s a sudden beep followed by the word "Alert".

有什么办法让iOS播放UIActionSheet播放的声音?它是突然的哔哔声,后面跟着“警报”。

I've searched the documentation and haven't been able to find anything that looks appropriate.

我搜索了文档,没有找到任何看起来合适的东西。

3 个解决方案

#1


2  

Not all behaviors of system controls can be reimplemented exactly using the UIAccessibility protocol. There is no public API to issue an accessibility hint tone like that. What you can do, however, is describe the control and transition in such a way that VoiceOver and other assistive clients know to alert the user.

不是所有的系统控件行为都可以使用UIAccessibility协议重新实现。没有公共API来发出这样的可访问性提示音。但是,您所能做的是,以一种VoiceOver和其他辅助客户知道如何通知用户的方式来描述控件和转换。

Depending on how your app is implemented, you might need to notify UIAccessibility that screen content has changed using UIAccessibilityPostNotification(), which accepts two parameters: the notification type and object. For a screen change notification, the object represents the next element that should receive focus. VoiceOver will process this notification, issue a tone, and move the cursor to the specified element.

根据应用程序的实现方式,您可能需要通知UIAccessibility,使用UIAccessibilityPostNotification()屏幕内容已经更改,它接受两个参数:通知类型和对象。对于屏幕更改通知,对象表示应该接收焦点的下一个元素。VoiceOver将处理这个通知,发出一个音调,并将光标移到指定的元素。

In general, you shouldn't be trying to "get UIAccessibility to" do anything at all. The protocol lets you describe the content and state of your app. It's up to each assistive client to translate these descriptions into an alternative interface as it sees fit. VoiceOver is not the only accessibility feature that relies on UIAccessibility! If you ape its behavior in your app, you could confuse VoiceOver users and alienate users of other assistive features such as Switch Control.

一般来说,您不应该尝试“获得UIAccessibility”来做任何事情。该协议允许您描述应用程序的内容和状态。每个辅助客户端都可以根据需要将这些描述转换为可选接口。VoiceOver不是唯一一个依赖UIAccessibility的可访问功能!如果你在你的应用中模仿它的行为,你可能会混淆语音用户,疏远其他辅助功能的用户,比如切换控件。

Edit: Another answer suggests playing the sound yourself. Once again, I'd strongly recommend against introducing your own sounds for scenarios already covered by VoiceOver. System sound icons convey more than just the context. They also assure users that a particular control is standard and predictable, implementing all expected behaviors. For quick example, does your custom sheet support the two-finger scrub gesture (accessibility escape)? The system sheet does and people will expect it if they hear the sheet sound.

编辑:另一个答案是建议你自己播放声音。再一次,我强烈建议不要在配音之前的场景中引入你自己的声音。系统声音图标传达的不仅仅是内容。它们还向用户保证,特定的控件是标准的、可预测的,可以实现所有预期的行为。例如,您的自定义表是否支持两个手指擦洗手势(可访问性)?系统表是这样的,如果人们听到它的声音,他们就会期待它。

#2


0  

There are many ways to play audio with help of System Sound Services, AVAudioPlayer, Audio Queue Services, and OpenAL. Without outside support libraries, the two easiest ways by far are System Sound Services and AVAudioPlayer.

在系统声音服务、AVAudioPlayer、音频队列服务和OpenAL的帮助下,有许多方法可以播放音频。如果没有外部支持库,到目前为止最简单的两种方法是系统声音服务和AVAudioPlayer。

when will you have click button you can play, play at delay time, duration play etc., here the example for AVAudioPlayer

什么时候你会有点击按钮,你可以播放,延迟时间播放,持续播放等等,这里是AVAudioPlayer的例子

   NSError *error;
   AVAudioPlayer *alertSound = [[AVAudioPlayer alloc]
        initWithContentsOfURL:musicURL error:&error];
    [alertSound prepareToPlay];
    [alertSound play];

Edited:

编辑:

- (BOOL)playAtTime:(NSTimeInterval)time

The number of seconds to delay playback, relative to the audio output device’s current time.

延迟播放的秒数,相对于音频输出设备的当前时间。

https://developer.apple.com/library/ios/documentation/AVFoundation/Reference/AVAudioPlayerClassReference/Reference/Reference.html#//apple_ref/occ/instm/AVAudioPlayer/playAtTime:

https://developer.apple.com/library/ios/documentation/AVFoundation/Reference/AVAudioPlayerClassReference/Reference/Reference.html / / apple_ref / occ / instm / AVAudioPlayer / playAtTime:

#3


0  

I'm fairly sure that the sounds that you are taking about comes from the "screen change" notification. It is an accessibility notification that is (from the documentation)

我确信你听到的声音来自“屏幕改变”通知。它是一个可访问性通知(来自文档)

posted by an application when a new view appears that comprises a major portion of the screen.

应用程序在显示包含屏幕主要部分的新视图时发布的。

When you post if within your application then you can pass either a string that will be read or the element that focus should move to. In the case of the alert view, focus moves to the alert view so I would assume that UIKit posts the alert view as the second argument.

当您在应用程序中发布if时,您可以传递将要读取的字符串或焦点应该移动到的元素。在alert视图中,焦点移动到alert视图,所以我假设UIKit将alert视图作为第二个参数。

To do this for your own view, you would do something like this:

为了你自己的观点,你可以这样做:

UIAccessibilityPostNotification(UIAccessibilityScreenChangedNotification,
                                yourNewViewThatShouldGetFocus);

#1


2  

Not all behaviors of system controls can be reimplemented exactly using the UIAccessibility protocol. There is no public API to issue an accessibility hint tone like that. What you can do, however, is describe the control and transition in such a way that VoiceOver and other assistive clients know to alert the user.

不是所有的系统控件行为都可以使用UIAccessibility协议重新实现。没有公共API来发出这样的可访问性提示音。但是,您所能做的是,以一种VoiceOver和其他辅助客户知道如何通知用户的方式来描述控件和转换。

Depending on how your app is implemented, you might need to notify UIAccessibility that screen content has changed using UIAccessibilityPostNotification(), which accepts two parameters: the notification type and object. For a screen change notification, the object represents the next element that should receive focus. VoiceOver will process this notification, issue a tone, and move the cursor to the specified element.

根据应用程序的实现方式,您可能需要通知UIAccessibility,使用UIAccessibilityPostNotification()屏幕内容已经更改,它接受两个参数:通知类型和对象。对于屏幕更改通知,对象表示应该接收焦点的下一个元素。VoiceOver将处理这个通知,发出一个音调,并将光标移到指定的元素。

In general, you shouldn't be trying to "get UIAccessibility to" do anything at all. The protocol lets you describe the content and state of your app. It's up to each assistive client to translate these descriptions into an alternative interface as it sees fit. VoiceOver is not the only accessibility feature that relies on UIAccessibility! If you ape its behavior in your app, you could confuse VoiceOver users and alienate users of other assistive features such as Switch Control.

一般来说,您不应该尝试“获得UIAccessibility”来做任何事情。该协议允许您描述应用程序的内容和状态。每个辅助客户端都可以根据需要将这些描述转换为可选接口。VoiceOver不是唯一一个依赖UIAccessibility的可访问功能!如果你在你的应用中模仿它的行为,你可能会混淆语音用户,疏远其他辅助功能的用户,比如切换控件。

Edit: Another answer suggests playing the sound yourself. Once again, I'd strongly recommend against introducing your own sounds for scenarios already covered by VoiceOver. System sound icons convey more than just the context. They also assure users that a particular control is standard and predictable, implementing all expected behaviors. For quick example, does your custom sheet support the two-finger scrub gesture (accessibility escape)? The system sheet does and people will expect it if they hear the sheet sound.

编辑:另一个答案是建议你自己播放声音。再一次,我强烈建议不要在配音之前的场景中引入你自己的声音。系统声音图标传达的不仅仅是内容。它们还向用户保证,特定的控件是标准的、可预测的,可以实现所有预期的行为。例如,您的自定义表是否支持两个手指擦洗手势(可访问性)?系统表是这样的,如果人们听到它的声音,他们就会期待它。

#2


0  

There are many ways to play audio with help of System Sound Services, AVAudioPlayer, Audio Queue Services, and OpenAL. Without outside support libraries, the two easiest ways by far are System Sound Services and AVAudioPlayer.

在系统声音服务、AVAudioPlayer、音频队列服务和OpenAL的帮助下,有许多方法可以播放音频。如果没有外部支持库,到目前为止最简单的两种方法是系统声音服务和AVAudioPlayer。

when will you have click button you can play, play at delay time, duration play etc., here the example for AVAudioPlayer

什么时候你会有点击按钮,你可以播放,延迟时间播放,持续播放等等,这里是AVAudioPlayer的例子

   NSError *error;
   AVAudioPlayer *alertSound = [[AVAudioPlayer alloc]
        initWithContentsOfURL:musicURL error:&error];
    [alertSound prepareToPlay];
    [alertSound play];

Edited:

编辑:

- (BOOL)playAtTime:(NSTimeInterval)time

The number of seconds to delay playback, relative to the audio output device’s current time.

延迟播放的秒数,相对于音频输出设备的当前时间。

https://developer.apple.com/library/ios/documentation/AVFoundation/Reference/AVAudioPlayerClassReference/Reference/Reference.html#//apple_ref/occ/instm/AVAudioPlayer/playAtTime:

https://developer.apple.com/library/ios/documentation/AVFoundation/Reference/AVAudioPlayerClassReference/Reference/Reference.html / / apple_ref / occ / instm / AVAudioPlayer / playAtTime:

#3


0  

I'm fairly sure that the sounds that you are taking about comes from the "screen change" notification. It is an accessibility notification that is (from the documentation)

我确信你听到的声音来自“屏幕改变”通知。它是一个可访问性通知(来自文档)

posted by an application when a new view appears that comprises a major portion of the screen.

应用程序在显示包含屏幕主要部分的新视图时发布的。

When you post if within your application then you can pass either a string that will be read or the element that focus should move to. In the case of the alert view, focus moves to the alert view so I would assume that UIKit posts the alert view as the second argument.

当您在应用程序中发布if时,您可以传递将要读取的字符串或焦点应该移动到的元素。在alert视图中,焦点移动到alert视图,所以我假设UIKit将alert视图作为第二个参数。

To do this for your own view, you would do something like this:

为了你自己的观点,你可以这样做:

UIAccessibilityPostNotification(UIAccessibilityScreenChangedNotification,
                                yourNewViewThatShouldGetFocus);