如何解决UIPickerView 辅助功能旁白问题
当 VoiceOver 启用时,无论我们滑动到哪一行,UIPickerView 的画外音总是说“#Item 1 of #TotalNumberOfItems”。 以编程方式,所有元素都使用正确的选定索引进行更新,但 VoiceOver 始终显示“#TotalNumberOfItems 的#Item 1”
让我知道是否有人在 PickerView 中遇到过这个问题?
一些观察:
- 如果我们离开应用一段时间然后滑动,索引会正确发音一次,然后同样的问题仍然存在
- 如果我们在滑动后点击选择器行,索引会正确发音
- 每次我们滑动行时,didSelect 都会被调用 2 次。
- DatePicker 工作正常
- 默认提醒应用有一些 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
解决方法
找到了相同的解决方法。发布包含附加到实际字符串的索引的公告。
-(void) pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{...
UIAccessibilityPostNotification(UIAccessibilityAnnouncementNotification,voiceOverText);
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。