1

我试图了解 UITableView 可访问性是如何工作的(以便将支持添加到以类似方式工作的其他一些库)。所以我在 UITableView 的MyTableView子类中实现了UIAccessibilityContainer 协议

首先,我需要呈现可访问的数据源:

- (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 错误:找不到我的模拟父母,很可能我已经过时了。

我正在尝试调查,除非有人尽快提出想法,否则我会发布结果。

4

1 回答 1

0

尝试在 UITableviewVell 类中实现那些 UIAccessibilityProtocal 方法。使单元格可访问并检查。

于 2014-02-24T12:15:05.623 回答