【问题标题】:UIPickerView Accessibility VoiceOver IssueUIPickerView 辅助功能旁白问题
【发布时间】:2023-03-05 10:13:01
【问题描述】:

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

如果有人在 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

【问题讨论】:

标签: ios objective-c accessibility uipickerview voiceover


【解决方案1】:

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-12-08
    • 1970-01-01
    • 2019-01-23
    • 2016-06-03
    • 1970-01-01
    相关资源
    最近更新 更多