问题
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