如何在模拟器上发布 UIAccessibility 公告?

How do I make UIAccessibility announcement on a simulator?

我有一个简单的视图控制器,它在 viewDidLoad() 中执行此操作。

DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 10) {
    UIAccessibility.post(notification: .announcement, argument: "Hello world.")
}

当我在我的设备上启用画外音时,效果非常好。

但是,在模拟器上,公告不会运行。我试过使用辅助功能检查器,但我无法让画外音宣布这一点。

是否有任何已知的解决方法?我正在 运行宁 Xcode 11,iOS 13 个模拟器。

模拟器上似乎没有 VoiceOver 运行。

它需要 运行 在设备上。我认为您可以在模拟器上做的最好的事情是使用可访问性检查器来检查标签、提示等

Debug Accessibility in iOS Simulator with the Accessibility Inspector

The Accessibility Inspector displays accessibility information about each accessible element in an app. You can use the Accessibility Inspector to simulate VoiceOver interaction with the accessible elements in your app to examine the information they provide.

Note: The Accessibility Inspector is helpful for testing the accessibility of your app during development, but it is no substitute for testing your app with VoiceOver on a physical device. For one thing, the Accessibility Inspector does not speak accessibility information, so you can’t hear how your element descriptions will sound. Even though the Accessibility Inspector is ideal for quickly verifying that elements supply appropriate accessibility information, you should test your app on a device, with VoiceOver turned on, to make sure that it behaves as users expect. See Test Accessibility on Your Device with VoiceOver for some tips on how to do this.

Reference