简体   繁体   中英

How do I make UIAccessibility announcement on a simulator?

I have a simple view controller which performs this in viewDidLoad() .

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

When I have Voiceover enabled on my device, this works perfectly fine.

However, on a simulator, the announcement does not run. I have tried playing around with the accessibility inspector but I cannot get Voiceover to announce this.

Are there any known workarounds? I'm running Xcode 11, iOS 13 Simulators.

VoiceOver does not seem to run on the simulator.

It needs to run on device. The best I think you can do on the simulator is use the accessibility inspector to check labels, hints etc

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM