[英]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:)
方法上,我将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);
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.