OGeek|极客世界-中国程序员成长平台

标题: ios - 自定义 View (如收藏 View )上的辅助功能旁白 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-11 20:34
标题: ios - 自定义 View (如收藏 View )上的辅助功能旁白

目前我正在处理自定义 View 。

我需要在标准 UICollectioView 中实现 VoiceOver 的行为。当我将焦点从自定义 View 层次结构之外的元素转换为层次结构中的元素时,VoitserOver 读取自定义 View 的可访问性标签,然后读取所选 View 的可访问性标签

@interface FBMinimizedPlayerControlPanelView ()

@property (nonatomic, strong) ImageView *artworkView;
@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UILabel *subtitleLabel;
@property (nonatomic, strong) ImageContainer *togglePlayPauseButton;

@end

@implementation FBMinimizedPlayerControlPanelView

- (instancetype)initWithFrameCGRect)frame {

    self = [super initWithFrame:frame];
    if (self) {
        [self setUp];
    }

    return self;
}

- (void)setUp {

//    self.isAccessibilityElement = YES;
    self.accessibilityLabel = @"Miniplayer.";
    self.accessibilityHint = @"Double tap to expand the miniplayer.";
//    self.accessibilityElementsHidden = YES;

//set up code 

    [self.togglePlayPauseButton configureWithAccessibilityLabel"lay" forState:BEToggleButtonStateSelected];
    [self.togglePlayPauseButton configureWithAccessibilityLabel"ause" forState:BEToggleButtonStateNormal];

}

- (nullable NSArray *)accessibilityElements {


    return @[self.togglePlayPauseButton];
}

@end

现在,当我打开 VoiceOver 时,它只读取暂停/播放按钮,但我希​​望行为与 UICollectionView 中一样,一开始读取 collectionView 的 accessibilityLabel,然后读取 item accessibilityLabel。

例如: Collection View 可访问性标签:“ Collection View ”, 单元格内容标签accessibilityLabel: "单元格内容标签",

在我上面描述的 VoiceOver 红色的情况下,它就像:“collectionView,单元格的内容标签”(仅当先前的焦点不是来自 collectionView 的 subview 时);



Best Answer-推荐答案


为了更好地被 VoiceOver 分析, Collection View 可以被视为一个数组,一旦使用 adjustable 特征定义,就应该遍历该数组。

然后必须将 Collection View 的每个元素定义为 UIAccessibilityElement

要了解应该如何实现,我建议您观看 WWDC 2018 - 提供卓越的可访问性体验视频,其内容完美总结here并且其提供的示例可以是downloaded .

关于ios - 自定义 View (如收藏 View )上的辅助功能旁白,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52310057/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4