Set voice over focus on UITextView

痴心易碎 提交于 2019-12-11 18:27:51

问题


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


回答1:


Very simple. Just do this:

UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification, textView);

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.

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.



来源:https://stackoverflow.com/questions/14401772/set-voice-over-focus-on-uitextview

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