UIPickerView 辅助功能旁白问题 [英] UIPickerView Accessibility VoiceOver Issue

查看:30
本文介绍了UIPickerView 辅助功能旁白问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当 VoiceOver 启用时,无论我们滑动到哪一行,UIPickerView 的画外音总是说#Item 1 of #TotalNumberOfItems".以编程方式,所有元素都使用正确的选定索引进行更新,但 VoiceOver 始终显示#TotalNumberOfItems 的#Item 1"

When VoiceOver is enabled, voice-over for the UIPickerView always says "#Item 1 of #TotalNumberOfItems" no matter to which row we swipe. Programatically all the elements are getting updated with the correct selected index but the VoiceOver always says "#Item 1 of #TotalNumberOfItems"

让我知道是否有人在 PickerView 中遇到过这个问题?

Let me know if anyone came across this issue in PickerView?

一些观察:

  1. 如果我们离开应用一段时间然后滑动,索引会正确发音一次,然后同样的问题仍然存在
  2. 如果我们在滑动后点击选择器行,索引会正确发音
  3. 每次我们滑动行时,didSelect 都会被调用 2 次.
  4. DatePicker 工作正常
  5. 默认提醒应用有一些 PickerViews,画外音按预期工作.(虽然发现上下滚动时索引细节不对)

@implementation ViewController
    - (void)viewDidLoad
    {
        [super viewDidLoad];
        self.normalPicker.backgroundColor = [UIColor blackColor];
        self.categories = [[NSMutableArray alloc] initWithObjects:@"Apple", @"Bat", @"Cat", @"Dog", @"Elephant", @"Fish", @"Goat",@"Hen", nil];
    }
    
    - (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
    {
        return 1;
    }
    - (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
    {
        return self.categories.count;
    }
    
    - (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {
        NSLog(@"DidSelect: Row = %@", self.categories[row]);
    }
    
    - (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view {
        UILabel *label = nil;
        if (view == nil) {
            label = [UILabel new];
            label.adjustsFontSizeToFitWidth = NO;
            label.textAlignment = NSTextAlignmentCenter;
            label.textColor = [UIColor redColor];
        } else {
            label = (UILabel *) view;
        }
    
        NSString *text = self.categories[row];
        label.text = text;
        return label;
    }
    
    @end

推荐答案

找到了相同的解决方法.发布包含附加到实际字符串的索引的公告.

Found a workaround for the same. Make an announcement including the index appending to the actual string.

-(void) pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{...
    UIAccessibilityPostNotification(UIAccessibilityAnnouncementNotification, voiceOverText);
}

这篇关于UIPickerView 辅助功能旁白问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆