【问题标题】:Accessibility - UIPickerView as inputView可访问性 - UIPickerView 作为 inputView
【发布时间】:2020-02-20 13:53:13
【问题描述】:

我使用UIPickerView 作为UITextField 的输入视图。

self.pickerView = [[UIPickerView alloc]initWithFrame:CGRectZero];

self.pickerView.dataSource = self.datasource;
self.pickerView.delegate = self.delegate;

//additional setups

self.textField.inputView = self.pickerView;

一切正常,但是当我激活画外音并开始循环播放时,画外音开始发出错误的通知。

我做了一些研究,并在 github 上找到了一个与遇到相同问题的人的 repo,但我找不到任何解决方案。

【问题讨论】:

    标签: ios uipickerview voiceover


    【解决方案1】:

    我找到了解决这种情况的方法。在pickerView(_:didSelectRow:inComponent:) 方法中,我使用UIAccessibilityPostNotification 和UIAccessibilityAnnouncementNotification,传递选择的项目,强制画外音做出正确的声明。

    目标-C:

    -(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {
        if(UIAccessibilityIsVoiceOverRunning()){
            UIAccessibilityPostNotification(UIAccessibilityAnnouncementNotification, self.items[row]);
        }
    }
    

    斯威夫特:

    func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
        if(UIAccessibility.isVoiceOverRunning){
            UIAccessibility.post(notification: UIAccessibility.Notification.announcement, argument: self.items);
        }
    }
    

    【讨论】:

      猜你喜欢
      • 2014-01-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-08-07
      • 1970-01-01
      相关资源
      最近更新 更多