启用 VoiceOver 后,无论我们滑动到哪一行,UIPickerView 的画外音始终显示“#Item 1 of #TotalNumberOfItems”。
以编程方式,所有元素都会使用正确的选定索引进行更新,但 VoiceOver 始终显示“#Item 1 of #TotalNumberOfItems”
请告诉我是否有人在 PickerView 中遇到过这个问题?
一些观察:
- 如果我们离开应用程序一段时间然后滑动,索引会正确发音一次,然后同样的问题仍然存在
- 如果我们在滑动后点击选择器行,索引会正确发音
- 每次我们滑动行时,didSelect 都会被调用两次。
- 日期选择器工作正常
- 默认提醒应用程序有一些 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);
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)