ios - iOS Objective-C VoiceOver Updating Available Accessible Elements
问题描述
I had a problem with VoiceOver focusing the wrong view (not the first one) when arriving to a ViewController. I was trying to solve it by making accessibilityElements contain only the view I would like to focus, and after 1 second clear it.
- (void)viewDidLoad
{
[super viewDidLoad];
self.view.accessibilityElements = @[self.firstView];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, NSEC_PER_SEC), dispatch_get_main_queue(), ^{
self.view.accessibilityElements = nil;
});
}
This is working, however there is a drawback. Focus becomes stucked on the firstView, meaning that swiping left and right doesn't change the focus. The only way to get "unstucked" is to tap on another element.
So how can I notify the system that an update happened to accessibilityElements? I would like the swiping gestures to work.
解决方案
When you set your accessibilityElements
to nil, notify the update using the UIAccessibilityScreenChangedNotification
with the accessibility element to be focused as incoming parameter.
You will be able to notify the system and using swiping gestures as desired.
推荐阅读
- java - 将工件部署到 Nexus 时找不到工件
- php - 90天后SQL替换表中的值
- cytoscape - RWRMTN 应用程序在 Cytoscape 中加载数据集需要哪些要求?
- casl - 使用 Ivy 和 CASL 构建问题
- awk - 如何在不匹配特定字符串的第一次和最后一次出现之前和之后的所有行的同时保留一行的内容?
- airflow - 气流 + OpenLDAP
- php - 无法 POST 到 PHP 后端服务器 | “异常”:“[对象](BadMethodCallException(代码:0):方法应用程序
- javascript - 将对象数组转换为以下结构
- android - 在 ionic 中启用 GPS
- python - FileNotFoundError 试图使用 selenium 和 webdriver 自动响应以在谷歌上形成