gpt4 book ai didi

iOS Objective-C VoiceOver 更新可用的可访问元素

转载 作者:行者123 更新时间:2023-11-29 11:28:45 28 4
gpt4 key购买 nike

当到达 ViewController 时,我遇到了 VoiceOver 聚焦错误 View (不是第一个 View )的问题。我试图通过让 accessibilityElements 只包含我想要关注的 View 来解决它,并在 1 秒后清除它。

- (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;
});
}

这是有效的,但是有一个缺点。焦点停留在第一个 View 上,这意味着左右滑动不会改变焦点。 “摆脱卡住”的唯一方法是点击另一个元素。

那么我如何通知系统 accessibilityElements 发生了更新?我希望滑动手势起作用。

最佳答案

当您将 accessibilityElements 设置为 nil 时,使用 UIAccessibilityScreenChangedNotification 通知更新将可访问性元素作为传入参数聚焦。

您将能够根据需要通知系统并使用滑动手势

关于iOS Objective-C VoiceOver 更新可用的可访问元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55827178/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com