繁体   English   中英

辅助功能 - UIPickerView 作为 inputView

[英]Accessibility - UIPickerView as inputView

我使用UIPickerView作为UITextField的 inputView 。

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

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

//additional setups

self.textField.inputView = self.pickerView;

一切正常,但是当我激活画外音并开始在 itens 中循环时,画外音开始发出不正确的公告。

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

我找到了解决这种情况的方法。 pickerView(_:didSelectRow:inComponent:)方法上,我将UIAccessibilityPostNotificationUIAccessibilityAnnouncementNotification一起使用,传递选择的项目,强制画外音发出正确的通知。

目标-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);
    }
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM