在UITextView上设置语音焦点 [英] Set voice over focus on UITextView

查看:107
本文介绍了在UITextView上设置语音焦点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在iOS 6中对我的元素(例如 UITextView )进行过焦点设置?

How can I set voice over focus on my element (such like UITextView) in iOS 6. Is it possible?

推荐答案

非常简单。只是这样做:

Very simple. Just do this:

UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification, textView);

请注意,它可能不起作用,具体取决于您在何时何地使用它。如果您尝试将焦点设置为 viewDidLoad 中的特定元素,则该代码可能无法正常工作。这是因为VoiceOver会自己尝试将VoiceOver焦点设置为最初的元素。如果VoiceOver在处理尝试设置焦点之前执行了此操作,则代码将起作用。但是,如果VoiceOver在处理完您的尝试后开始设置初始的焦点元素,您的代码似乎将失败。

Note that it may not work, depending on where and when you use it. If you're trying to set the focus to a particular element from viewDidLoad, the code probably won't work correctly. This is because VoiceOver makes its own attempt to set the VoiceOver focus on an element initially; if VoiceOver does this before it processes your attempt to set focus, your code will work. But if VoiceOver gets around to setting the initial focused element after it processes your attempt, your code will appear to fail.

viewDidLoad 将使用 performSelector:withObject:withDelay:,以确保在VoiceOver的初始焦点设置之后处理您的呼叫。

A somewhat more reliable way to do this in viewDidLoad is to use performSelector:withObject:withDelay:, to ensure that your call is processed after VoiceOver's initial focus setting.

这篇关于在UITextView上设置语音焦点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆