菜鸟教程小白 发表于 2022-12-13 16:37:40

ios - 当呈现新 View 时,如何控制默认选择的画外音元素是什么?


                                            <p><p>当一个新的 ViewController 出现时,默认通过语音选择的元素似乎是页面上的第一个元素,通常是后退按钮。 </p>

<p>如何改变这种行为,以便默认选择不同的元素?</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>您可以使用 <a href="http://a11y.forge.orange-labs.fr/mobile_EN/dev-ios.html#notify-a-content-change" rel="noreferrer noopener nofollow">UIAccessibilityPostNotification</a> 定义第一个选定元素例如,您的新 ViewController 的 <code>viewDidAppear</code> 中的方法。</p>
<p>提供您的可访问元素作为此函数的传入参数,它应该可以工作。</p>
<pre><code>override func viewDidAppear(_ animated: Bool) {
    super.viewDidAppear(animated)
   
    UIAccessibilityPostNotification(UIAccessibilityScreenChangedNotification,
                                    yourFirstDisplayedAccessibleElement)
}
</code></pre>
<p>我建议使用 <code>UIAccessibilityScreenChangedNotification</code> 因为与 <code>UIAccessibilityLayoutChangedNotification</code> 不同,VoiceOver 会读出新焦点元素的提示 <em>(不知道为什么???) </em>.</p></p>
                                   
                                                <p style="font-size: 20px;">关于ios - 当呈现新 View 时,如何控制默认选择的画外音元素是什么?,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/37331001/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/37331001/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - 当呈现新 View 时,如何控制默认选择的画外音元素是什么?