Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
当我单击某个按钮时,我会弹出一个警报。我在我的设备上启用了旁白,它开始阅读弹出窗口中的内容。现在,我想发布一个自定义公告,例如
UIAccessibility.post(notification: .announcement, argument: "Hello world.")
但这不起作用,因为我只需要在 Voiceover 完成阅读屏幕上的所有内容时发布此通知。
当 Voiceover 读完所有内容后,我是否可以发布此通知?
您可以订阅(添加观察者)到 NotificationCenter 事件announcementDidFinishNotification
announcementDidFinishNotification
https://developer.apple.com/documentation/uikit/uiaccessibility/1620202-announcementdifinishnotificatio
或者voiceOverStatusDidChangeNotification
voiceOverStatusDidChangeNotification
https://developer.apple.com/documentation/uikit/uiaccessibility/2865862-voiceoverstatusdidchangenotifica
您添加到观察者的函数选择器将_ sender: Notification像其他观察者选择器一样使用参数调用。让我知道这有帮助;)
_ sender: Notification