首页 文章

BottomBar BarButtonItem Voice Over Accessibility已损坏

提问于
浏览
0

我注意到当BarButtonItem放置在View的底栏时,标准的Voice Over行为存在一些问题 .

在测试应用程序中,我做了以下简单的视图

Test App Showing Top Bar, Bottom Bar button items and a label

使用以下代码我将更新所有3个文本元素,以便它们每秒计数 .

@interface ViewController ()

@property (weak, nonatomic) IBOutlet UILabel *testLabel;
@property (weak, nonatomic) IBOutlet UIBarButtonItem *testBarButtonItem;
@property (weak, nonatomic) IBOutlet UIBarButtonItem *testBottomBarItem;

@property (nonatomic, strong) NSTimer *timer;
@property (nonatomic) NSInteger count;

@end

@implementation ViewController

- (void)viewDidLoad
{
  [super viewDidLoad];
  // Do any additional setup after loading the view, typically from a nib.

  self.count = 0;
  self.timer = [NSTimer scheduledTimerWithTimeInterval:1.0f target:self selector:@selector(updateTimer:) userInfo:nil repeats:YES];

  // run the timer for the common modes so it's not interrupted with scrolling - should be ticked in pretty much all modes now
  [[NSRunLoop currentRunLoop] addTimer:self.timer forMode:NSRunLoopCommonModes];

  self.testLabel.accessibilityTraits |= UIAccessibilityTraitUpdatesFrequently;
  self.testBarButtonItem.accessibilityTraits |= UIAccessibilityTraitUpdatesFrequently;
  self.testBottomBarItem.accessibilityTraits |= UIAccessibilityTraitUpdatesFrequently;
}

-(void)updateTimer:(NSTimer*)theTimer
{
  self.testLabel.text = [NSString stringWithFormat:@"Label with value %d", (int)self.count];
  self.testBarButtonItem.title = [NSString stringWithFormat:@"Top Item with title %d", (int)self.count];
  self.testBottomBarItem.title = [NSString stringWithFormat:@"Bottom Item with title %d", (int)self.count];
  self.count++;
}

在启用了Voice Over的iPhone 6上测试此应用程序,会发生以下情况

  • 顶栏按钮项在更新其内容时发出脉冲

  • 由于UIAccessibilityTraitUpdatesFrequently trait被设置,顶部栏按钮项正确读出其更新内容

  • 由于UIAccessibilityTraitUpdatesFrequently trait被设置,中心的Label正确读出更新的内容

  • 底栏按钮项目未正确读出其更新内容,即使它也具有UIAccessibilityTraitUpdatesFrequently特征集

  • 使用从顶部栏按钮项开始的左/右滑动导航辅助功能元素时,选择正确向下移动到带有右滑动的标签,但是从那里右滑动将选择带到视图的左上角(其中没有控件)所在) . 然后它会读出最初的底栏按钮内容"Bottom Item With title 0",无论底部按钮实际读取的是什么 . 只有在主动选择底部条形项目时才会实际正确选择它并将其读出 . 但正如已经描述的那样,它不会继续阅读它

我认为导航错误在iOS 8.4中可能是新的,因为我在我的主应用程序中没有注意到我长时间一直在测试语音,但我可能错过了它 .

我在我自己的应用程序中经常使用UIAccessibilityTraitUpdates并没有太大的成功,但我看到那些似乎正在使用它的其他应用程序 . 因此,如果有人能够指出我做错的事情那会很棒 . 否则我想我会记录雷达的错误 .

作为参考,我现在把整个项目作为zip下载here

这里有一个关于这个bug的视频

https://youtu.be/QokQ0MDGyZM

1 回答

  • 1

    你似乎误解了 UIAccessibilityTraitUpdatesFrequently 的作用 . 它不能确保您的内容在动态变化时被读出 . 它确保过度冗长的内容(如计时器)不会读出每次更新 . 例如,如果您将焦点放在每秒更新的计时器上 . VoiceOver会读出来

    1 2 3 4 ...

    但是,让我们说这是一个时间 . 所以它必须读出:

    1小时20分55秒1小时20分56秒......

    但是,当它读取整个第一个公告“... 55秒”时,计时器现在实际上读取1:21:00 . 然而它仍然读出“...... 56秒”,然后继续读出“... 57秒”同时,计时器和实际公告越来越远不同步 .

    如果VoiceOver没有聚焦,则没有任何内容会自动读出自动更新内容 . 这会造成严重破坏,并导致许多可访问性问题 . 开发人员通过适当地发布以下三个辅助功能通知来通知VoiceOver动态更改:

    UIAccessibilityLayoutChangedNotification
    UIAccessibilityScreenChangedNotification
    UIAccessibilityAnnouncementNotification
    

    请注意,在典型的测试环境中,这些行为有点不稳定 . 特别是我发现,您希望在打开应用程序之前确保拥有VoiceOver . 在应用程序启动时使用快速切换快捷方式是在通知系统中将VoiceOver错误输出的好方法 . 更好的方法是打开VoiceOver,重新启动手机,并在测试时将其保持打开状态 .

相关问题