语音只能看到一个页面的uicollectionview [英] voice over can only see a page of a uicollectionview

查看:280
本文介绍了语音只能看到一个页面的uicollectionview的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我有一个UICollectionView和一组UICollectionViewCells显示使用自定义UILayout。

So i have a UICollectionView with a set of UICollectionViewCells displayed using a custom UILayout.

我已经配置了UILayout布局所有的UICollectionViewCells几乎完全相同如何在ios上的照片应用程序中布局。

I've configured the UILayout to lay out all the UICollectionViewCells almost exactly the same as how they are laid out in the photos app on ios.

问题是,当开启语音覆盖时,用户正在遍历UICollectionViewCells滑动,当用户到达页面上最后一个可见的单元格,并尝试向前滑动到下一个单元格,它只是停止。

The problem is, it seems when voice over is turned on, and the user is traversing through the UICollectionViewCells using swipe, when the user gets to the last visible cell on the page, and tries to swipe forward to the next cell, it simply stops.

我知道在UITableView细胞将继续前进,表视图将自动向下滚动。

I know that in UITableView the cells will just keep moving forward, and the table view will scroll down automatically.

有人知道如何获得这种行为吗?

Does anyone know how to get this behaviour?

推荐答案

这个答案对我也有效。谢谢!

This answer worked for me, too. Thanks!

您必须启用其他电话才能使用此功能。否则你的方法(void)accessibilityElementDidBecomeFocused永远不会被调用。您必须对对象Cell启用辅助功能。

There is one other call you must have enabled to get this to work. Otherwise your method (void)accessibilityElementDidBecomeFocused will never get called. You must enable accessibility on the object Cell.


  1. 选项1:在ViewController中,将单元格实例设置为具有辅助功能。 p>

  1. Option 1: In ViewController, set the cell instance to have accessibility.

Cell *cell = [cv dequeueReusableCellWithReuseIdentifier:kCellID forIndexPath:indexPath];
[cell setIsAccessibilityElement:YES];


  • 选项2:在单元格对象中实现辅助功能界面:

  • Option 2: Implement the accessibility interface in the cell object:

    - (BOOL)isAccessibilityElement
    {
        return YES;
    }
    
    - (NSString *)accessibilityLabel {
        return self.label.text;
    }
    
    - (UIAccessibilityTraits)accessibilityTraits {
        return UIAccessibilityTraitStaticText;  // Or some other trait that fits better
    }
    
    - (void)accessibilityElementDidBecomeFocused
    {
        UICollectionView *collectionView = (UICollectionView *)self.superview;
        [collectionView scrollToItemAtIndexPath:[collectionView indexPathForCell:self] atScrollPosition:UICollectionViewScrollPositionCenteredHorizontally|UICollectionViewScrollPositionCenteredVertically animated:NO];
        UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification, self);
    }
    


  • 这篇关于语音只能看到一个页面的uicollectionview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆