【发布时间】:2013-06-09 09:36:22
【问题描述】:
我正在尝试了解 UITableView 可访问性的工作原理(以便将支持添加到以类似方式工作的其他一些库)。所以我在 UITableView 的 MyTableView 子类中实现了 UIAccessibilityContainer Protocol。
首先我需要使数据源可访问:
- (id<UITableViewDataSource>)dataSource
{
return (id<UITableViewDataSource>)[self valueForKey:@"_dataSource"];
}
然后我重新实现:
- (NSInteger)indexOfAccessibilityElement:(id)element
{
return [[self indexPathForCell:element] row];
}
- (NSInteger)accessibilityElementCount
{
return [[self dataSource] tableView:self numberOfRowsInSection:0];
}
并且可访问性仍然按预期工作。最后一步是实现 - (id)accessibilityElementAtIndex:(NSInteger)index:
- (id)accessibilityElementAtIndex:(NSInteger)index
{
return [[self dataSource] tableView:self cellForRowAtIndexPath:[NSIndexPath indexPathForRow:index inSection:0]];
}
但显然为 tableview 添加此方法可访问性停止工作,并且在导航(带画外音)到 tableview 时我只得到一个 VoiceOver“空列表”。有趣的事情单元格被正确返回,我收到大量 AX 错误:找不到我的模拟父母,很可能我已经过时了。
我正在尝试调查,除非有人更早提出想法,否则我会发布结果。
【问题讨论】:
标签: uitableview uiaccessibility