Moving Accessibility Voiceover cursor focus to a specific element

别说谁变了你拦得住时间么 提交于 2019-12-21 04:08:33

问题


I'm having an issue with moving the voiceover cursor to a specific element on viewDidAppear. I followed Apple's guidelines for focusing on a specific element, in this case a dismiss button, but the cursor ends up elsewhere

Here is my Code:

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];

UIAccessibilityPostNotification(UIAccessibilityScreenChangedNotification,
                                self.dismissButton);
}

Any help, ideas, would definitely be appreciated! thank you so much.


回答1:


If I remember correctly i was not able to reliably focus on elements on first of the view as VO will generally focus on the top of the view.

The code you are doing is correct, but at this point the system will trigger it's own event and override yours.

What you can try to do is post a notification with a delay. But that will result in focus jumping around a little bit when opening the view.

It's not much of an answer, but that is where I'm at at the moment. I'll update you if I figure out a way to do it.




回答2:


This answer may be of help.

Basically you need to wrap your elements in a container view if they're not in one already and then override the methods specified.

By giving your desired element a tag that is lower than the other elements you can have the view sort the array to ensure that it will be the first element in the accessibilityElements array used by VoiceOver. Or you can adapt the sort method to sort another way.




回答3:


FYI: As of iOS 11, both UIAccessibilityScreenChangedNotification and UIAccessibilityLayoutChangedNotification reliably focus Voice Over elements for me.



来源:https://stackoverflow.com/questions/20959699/moving-accessibility-voiceover-cursor-focus-to-a-specific-element

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