Ios 可访问性-UIPickerView作为inputView
我正在使用Ios 可访问性-UIPickerView作为inputView,ios,uipickerview,voiceover,Ios,Uipickerview,Voiceover,我正在使用UIPickerView作为UITextField的输入视图 self.pickerView = [[UIPickerView alloc]initWithFrame:CGRectZero]; self.pickerView.dataSource = self.datasource; self.pickerView.delegate = self.delegate; //additional setups self.textField.inputView = self.picke
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;
一切正常,但当我启动画外音并开始在iTen中循环时,画外音开始发出错误的公告
我做了一些研究,发现有人也有同样的问题,但我找不到任何解决办法。我找到了解决这个问题的办法。在
pickerView(uu2;:didSelectRow:incomonent:)
方法中,我使用UIAccessibilityPostNotification
和uiAccessibilityAnounceNotification
,传递所选项目,强制画外音做出正确的公告
目标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);
}
}
我为这个案子找到了一个解决办法。在
pickerView(uu2;:didSelectRow:incomonent:)
方法中,我使用UIAccessibilityPostNotification
和uiAccessibilityAnounceNotification
,传递所选项目,强制画外音做出正确的公告
目标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);
}
}