gpt4 book ai didi

ios - 为什么是 UIAccessibility.post(notification : . 公告,参数 : "arg") not announced in voice over?

转载 作者:行者123 更新时间:2023-12-01 15:22:10 28 4
gpt4 key购买 nike

在 iOS 中使用 Voice Over 时,调用 UIAccessibility.post(notification:argument:)宣布字段错误实际上并不宣布错误。

我有一个提交按钮,当聚焦按钮时,旁白会按照您的预期读取按钮标题。按下按钮时,画外音会再次朗读标题。当按下提交按钮时,我正在做一些验证,当出现字段错误时,我试图通过调用来宣布它:

if UIAccessibility.isVoiceOverRunning {
UIAccessibility.post(notification: .announcement, argument: "my field error")
}

有趣的是,如果我在调试器中的断点处停止,就会发生通知。当我不在断点处停止时,通知不会发生。

通知发布在主线程上,如果是 NotificationCenter.default ,我假设它是在它发布的同一个线程上处理的。我试图将调用分派(dispatch)到主队列,即使它已经在主线程上,但这似乎也不起作用。

我唯一能想到的是,通知是在画外音完成阅读提交按钮标题之前发布和观察的,并且公告通知不会中断当前的画外音。

我真的很感激这方面的任何帮助。

最佳答案

这是一个公认的 hacky 解决方案,但我能够通过稍微延迟调度到主线程来防止系统通知抢占我自己的通知:

DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
UIAccessibility.post(notification: .announcement, argument: "<Your text>")
}

关于ios - 为什么是 UIAccessibility.post(notification : . 公告,参数 : "arg") not announced in voice over?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55522345/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com