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
我在将配音光标移动到viewDidAppear上的特定元素时遇到问题。我遵循Apple的指导原则,专注于特定元素,在这种情况下是一个消除按钮,但光标最终会在其他地方
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.
任何帮助,想法,绝对会受到赞赏!非常感谢。
3 个解决方案
#1
8
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.
如果我没记错的话,我无法可靠地关注视图的第一个元素,因为VO通常会关注视图的顶部。
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
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.
通过为所需元素提供低于其他元素的标记,您可以使视图对数组进行排序,以确保它将成为VoiceOver使用的accessibilityElements数组中的第一个元素。或者您可以调整排序方法以另一种方式排序。
#3
1
FYI: As of iOS 11, both UIAccessibilityScreenChangedNotification
and UIAccessibilityLayoutChangedNotification
reliably focus Voice Over elements for me.
仅供参考:从iOS 11开始,UIAccessibilityScreenChangedNotification和UIAccessibilityLayoutChangedNotification都能可靠地为我调整Voice Over元素。
#1
8
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.
如果我没记错的话,我无法可靠地关注视图的第一个元素,因为VO通常会关注视图的顶部。
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
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.
通过为所需元素提供低于其他元素的标记,您可以使视图对数组进行排序,以确保它将成为VoiceOver使用的accessibilityElements数组中的第一个元素。或者您可以调整排序方法以另一种方式排序。
#3
1
FYI: As of iOS 11, both UIAccessibilityScreenChangedNotification
and UIAccessibilityLayoutChangedNotification
reliably focus Voice Over elements for me.
仅供参考:从iOS 11开始,UIAccessibilityScreenChangedNotification和UIAccessibilityLayoutChangedNotification都能可靠地为我调整Voice Over元素。