首页 > 解决方案 > 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.

标签: iosobjective-cvoiceover

解决方案


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.


推荐阅读