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

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

问题描述

所以我有一个 UICollectionView,其中包含一组使用自定义 UILayout 显示的 UICollectionViewCell.

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

我已将 UILayout 配置为所有 UICollectionViewCell 的布局几乎与它们在 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 中,将单元格实例设置为具有可访问性.

  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天全站免登陆