简体   繁体   English

TableViewCell中的CollectionView的iOS可访问性

[英]iOS Accessibility for CollectionView in a TableViewCell

I'm currently working on the accessibility of our project, and here is UICollectionView that is put into a custom UITableViewCell. 我目前正在研究项目的可访问性,这里是放入自定义UITableViewCell的UICollectionView。 This CollectionView has tens of cells that are arranged in multiply rows rather than one row. 此CollectionView具有数十个单元格,这些单元格以多行而不是一行排列。

It raises an issue that when you have voiceOver on and move the focus between the collectionViewCells by swiping left or right, the system thought you are swiping between tableViewCells, since collectionView is in the tableView, and the contentOffSet of the tableView will be changed according to the tableViewCell size, instead of the collectionViewCell size. 它引发了一个问题,当你打开voiceOver并通过向左或向右滑动在collectionViewCells之间移动焦点时,系统认为你在tableViewCells之间滑动,因为collectionView在tableView中,而tableView的contentOffSet将根据tableViewCell大小,而不是collectionViewCell大小。

CollectionView is already put in the the tableView and I don't think I can change this. CollectionView已经放在tableView中了,我认为我不能改变它。 So just wondering has anyone met this case before and is there anyway to make the collectionView accessible as normal? 所以只是想知道以前有没有人遇到过这个案例,无论如何都要使collectionView正常访问?

This is a known bug in Apple's SDK (sorry, I don't have a bug report reference) when nesting a collectionView inside a tableView. 当在tableView中嵌套collectionView时,这是Apple的SDK中的一个已知错误(抱歉,我没有错误报告参考)。 After some experimentation, I was able to work around it by using a UIView as a wrapper for my collectionView before adding it to my UITableViewCell's .contentView 经过一些实验,我可以通过使用UIView作为我的collectionView的包装器来解决它,然后将它添加到我的UITableViewCell的.contentView中

    UIView *wrapperView = [[UIView alloc] initWithFrame:cell.contentView.bounds];
    wrapperView.accessibilityElements = @[collectionView];
    [cell.contentView addSubview:wrapperView];
    [wrapperView addSubview:collectionView];

Just fix the problem by reconstructing the whole page, here are 2 things do not do to make your app more accessible: 只需通过重新构建整个页面来解决问题,这里有两件事情无法让您的应用更易于访问:

  1. Avoid adding a subview directly to the tableView/collectionView like 避免直接向tableView / collectionView添加子视图

    [tableView/collectionView addSubview:yourSubView]; [tableView / collectionView addSubview:yourSubView];

  2. Avoid adding a vertically scrollable collectionView to a tableViewCell. 避免将垂直可滚动的collectionView添加到tableViewCell。

    Adding a horizontally scrollable collectionView to a tableViewCell seems will not cause any issue. 将水平可滚动的collectionView添加到tableViewCell似乎不会导致任何问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM