我在表格视图中实现了所有辅助功能操作方法,并添加了“可调整”特征。我使用UITableView进行自定义控制,通过滚动选择项目。它没有要选择的典型行。它用于滚动,标记显示所选内容。类似于UIPickerView或Weightbot中的选择器。选择活动日期是自定义date picker control。
但iOS从不调用我的辅助功能操作方法。在表格视图中向上或向下轻拂Voice Over无法正常反应。它疯狂地跳来跳去。
我必须为语音设置代理或数据源吗?当用户像UIPickerView一样向上/向下滑动时,如何才能正确地向上/向下移动表格视图?
理解Apple如何使用VoiceOver可以访问UIDatePicker将会有很大帮助。它为每列使用UITableView。您可以在列之间拖动以选择列。然后你可以向上滑动增加或减少。
编辑:以递归方式转发有关UIDatePicker的信息,以了解其设置方式。
UIDatePicker:
_UIDatePickerView:
UIView:
_UIOnePartImageView:
_UIPickerWheelView:
_UIPickerViewSelectionBar:
UIPickerTableView:; contentOffset: {0, 2.19991e+06}>
UIPickerTableViewWrapperCell:
UITableViewCellContentView:
UIDatePickerWeekMonthDayView:
UILabel: {label = 28. Jul} {traits = staticText } {accessibilityIncrement} {accessibilityDecrement} {accessibilityScroll:} {accessibilityPerformEscape} {accessibilityPerformMagicTap}
在设置/实现时打印所有可用的可访问性相关内容。就像你可以看到的,奇怪的是,表视图单元格的UILabel实现了scroll方法。这对我来说没有意义。为什么是这样?为什么不是UIPickerTableView本身?并且在整个UIDatePicker中也没有可调整的特征。
这是我用来转储此信息的代码。为了确定,我在2秒延迟后最初在UIDatePicker上调用它。我把这段代码放在UIView上。
- (NSString *)description {
NSString *className = NSStringFromClass([self class]);
NSMutableString *str = [NSMutableString stringWithFormat:@"%@: ", className];
if (self.isAccessibilityElement) {
if (self.accessibilityLabel) {
[str appendFormat:@"{label = %@} ", self.accessibilityLabel];
}
UIAccessibilityTraits traits = self.accessibilityTraits;
[str appendString:@"{traits = "];
if (traits & UIAccessibilityTraitAdjustable) {
[str appendString:@"adjustable "];
}
if (traits & UIAccessibilityTraitAllowsDirectInteraction) {
[str appendString:@"interaction "];
}
if (traits & UIAccessibilityTraitButton) {
[str appendString:@"button "];
}
if (traits & UIAccessibilityTraitCausesPageTurn) {
[str appendString:@"pageTurn "];
}
if (traits & UIAccessibilityTraitHeader) {
[str appendString:@"header "];
}
if (traits & UIAccessibilityTraitImage) {
[str appendString:@"image "];
}
if (traits & UIAccessibilityTraitKeyboardKey) {
[str appendString:@"kbKey "];
}
if (traits & UIAccessibilityTraitLink) {
[str appendString:@"link "];
}
if (traits & UIAccessibilityTraitNone) {
[str appendString:@"none "];
}
if (traits & UIAccessibilityTraitNotEnabled) {
[str appendString:@"notEnabled "];
}
if (traits & UIAccessibilityTraitPlaysSound) {
[str appendString:@"sound "];
}
if (traits & UIAccessibilityTraitSearchField) {
[str appendString:@"search "];
}
if (traits & UIAccessibilityTraitSelected) {
[str appendString:@"selected "];
}
if (traits & UIAccessibilityTraitStaticText) {
[str appendString:@"staticText "];
}
if (traits & UIAccessibilityTraitSummaryElement) {
[str appendString:@"summaryElement "];
}
if (traits & UIAccessibilityTraitUpdatesFrequently) {
[str appendString:@"updatesFreq "];
}
[str appendString:@"} "];
if ([self respondsToSelector:@selector(accessibilityIncrement)]) {
[str appendString:@"{accessibilityIncrement} "];
}
if ([self respondsToSelector:@selector(accessibilityDecrement)]) {
[str appendString:@"{accessibilityDecrement} "];
}
if ([self respondsToSelector:@selector(accessibilityScroll:)]) {
[str appendString:@"{accessibilityScroll:} "];
}
if ([self respondsToSelector:@selector(accessibilityPerformEscape)]) {
[str appendString:@"{accessibilityPerformEscape} "];
}
if ([self respondsToSelector:@selector(accessibilityPerformMagicTap)]) {
[str appendString:@"{accessibilityPerformMagicTap} "];
}
}
return str;
}