我试图了解UITableView可访问性是如何工作的(以便将支持添加到其他以类似方式工作的库中)。因此,我在UIAccessibilityContainer的MyTableView子类中实现了UITableView协议。
首先,我需要使dataSource可访问:
- (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添加此方法可访问性停止工作,当我在(带有画外音)的表视图中导航时,我只得到一个VoiceOver“空列表”。有趣的事情单元格被正确地返回,我得到了大量的AX错误:找不到我的模拟父程序,很可能我已经过时了。
我正在调查,除非有人能更快地想出主意,否则我会发布结果的。
发布于 2014-02-24 12:15:05
尝试在UIAccessibilityProtocal类中实现这些UITableviewVell方法。使单元格可访问并检查。
https://stackoverflow.com/questions/17008301
复制相似问题