Exception when pausing voice over

梦想的初衷 提交于 2020-02-24 00:41:07

问题


I try to pause voice over and get an exception:

UIAccessibilityPostNotification(UIAccessibilityPauseAssistiveTechnologyNotification, UIAccessibilityNotificationVoiceOverIdentifier)

'NSInvalidArgumentException', reason: 'You must pass the identifier of the assistive technology to pause. See UIAccessibilityConstants.h for the list of valid values.'

What's wrong? Thanks!


回答1:


You must use an UIAccessibility.AssistiveTechnologyIdentifier like:

   UIAccessibility.post(notification: .pauseAssistiveTechnology,
                         argument: UIAccessibility.AssistiveTechnologyIdentifier.notificationVoiceOver)



回答2:


I too ran into this issue and despite the voice over identifier is marked being available since ios9 it still continues to crash on ios10. After looking into the documentation made me think that the 'pause / resume assistive technology' is not meant for voice over after all.

"Should be posted to pause an assistive technology's operations temporarily. For example, you may want to pause scanning in Switch Control while your app plays an animation. An identifier representing the assistive technology should be used as the argument. Currently, these notifications only apply to Switch Control. The notifications must be balanced. That is, every UIAccessibilityPauseAssistiveTechnologyNotification should be followed by a matching UIAccessibilityResumeAssistiveTechnologyNotification with the same argument. If the user performs an action that requires the assistive technology to resume operations, it may do so before it receives the corresponding UIAccessibilityResumeAssistiveTechnologyNotification. The argument is a NSString."



来源:https://stackoverflow.com/questions/41430129/exception-when-pausing-voice-over

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!