画外音焦点重置UICollectionView到第一个入口?

时间:2022-01-06 22:20:45

I’m using VoiceOver, and having an issue with a UICollectionView. I have an initial screen with ten buttons, each of which links through to one of ten cells in the collection view. The collection view is actually the full size of the screen, and each cell contains a child view controller. This all works fine with VoiceOver switched off, but when it’s switched on, activating one of the buttons in the middle of the set always causes the collection view to pop to its first cell, even if I didn’t tap the first button. I think this is because the VoiceOver “focus” goes to the first element it sees (i.e. the first cell).

我在用画外音,有一个UICollectionView的问题。我有一个带有10个按钮的初始屏幕,每个按钮都链接到集合视图中的10个单元中的一个。集合视图实际上是屏幕的全尺寸,每个单元格都包含一个子视图控制器。关闭VoiceOver可以正常工作,但当它被打开时,激活设置中间的一个按钮总是会让collection视图弹出到它的第一个单元格,即使我没有按下第一个按钮。我认为这是因为画外音“focus”进入它看到的第一个元素(即第一个单元格)。

I’ve tried using the UIAccessibilityScreenChangedNotification and the same with Layout with an argument of the cell in question, but it’s making no difference, it’s not popping to my required element, and is always popping to the first cell in the collection.

我已经尝试过使用UIAccessibilityScreenChangedNotification和具有问题单元格参数的布局一样,但这没有什么区别,它不是指向我所需要的元素,而是始终指向集合中的第一个单元格。

What could I be doing wrong here?

我在这里做错了什么?

I’m adding a snippet, this is called in viewDidLayoutSubviews, and works fine for the actual scrolling if VoiceOver is turned off. But as soon as VO is on, it breaks.

我添加了一个代码片段,在viewDidLayoutSubviews中调用,如果关闭了VoiceOver,它可以正常地滚动屏幕。

if (self.initialIndexPath) {
    [self.collectionView scrollToItemAtIndexPath:self.initialIndexPath atScrollPosition:UICollectionViewScrollPositionNone animated:NO];
    UIAccessibilityPostNotification(UIAccessibilityScreenChangedNotification, [self.collectionView cellForItemAtIndexPath:self.initialIndexPath]);
}

This works absolutely fine for actually focusing on the cell, but the VoiceOver portion is completely ignored, the notification does not shift the focus to that correct cell at all, it's always the first element in the first cell.

这对于真正关注单元格是非常有效的,但是VoiceOver部分完全被忽略了,通知根本没有将焦点转移到那个正确的单元格,它始终是第一个单元格中的第一个元素。

Also to note, the cells themselves are NOT accessibilityElements and should not be, they implement the UIAccessibilityContainer protocol, and so the title label of each cell would be where I'd like the focus to end up.

另外要注意的是,这些单元本身并不是可访问性元素,不应该是,它们实现了UIAccessibilityContainer协议,因此每个单元的标题标签将会是我想要关注的焦点。

1 个解决方案

#1


0  

This was a bug in iOS and is fixed now.

这是iOS中的一个bug,现在已经修复了。

I started to see this bug in iOS8. And reported a bug to Apple about this 6. Nov 2014. Was fixed in iOS 9.3.2.

我开始在iOS8中看到这个bug。并向苹果报告了这个问题。2014年11月。修正在iOS 9.3.2中。

There is nothing you can do as developer if you are on affected OS version. Recommend users of your app to update the OS.

如果您使用的是受影响的OS版本,那么作为开发人员,您无法做任何事情。建议你的应用用户更新操作系统。

#1


0  

This was a bug in iOS and is fixed now.

这是iOS中的一个bug,现在已经修复了。

I started to see this bug in iOS8. And reported a bug to Apple about this 6. Nov 2014. Was fixed in iOS 9.3.2.

我开始在iOS8中看到这个bug。并向苹果报告了这个问题。2014年11月。修正在iOS 9.3.2中。

There is nothing you can do as developer if you are on affected OS version. Recommend users of your app to update the OS.

如果您使用的是受影响的OS版本,那么作为开发人员,您无法做任何事情。建议你的应用用户更新操作系统。