【问题标题】:VoiceOver user interaction inside UITableViewCellUITableViewCell 内的 VoiceOver 用户交互
【发布时间】:2023-12-26 07:18:02
【问题描述】:

我有一个带有自定义 UITableViewCell CustomCell 的 UITableView
CustomCell 有一些启用用户交互的 UILabel
CustomCell 实现 touchesBegan:

- (void) touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event {
UITouch* touch = touches.anyObject;
    self.itemSelected=[touch view].tag;
    self.viewSelected=[touch view];
[super touchesBegan:touches withEvent:event];
}

如果我没有启用 VoiceOver,这很好用,touchBegan 被调用,并且正确的视图被“选中”

启用 VoiceOver 后,如果我执行“双击然后按住”,也会调用 touchesBegan,但与触摸事件关联的视图的类型为 UITableViewCellContentView。

知道我将如何保持这些用户与 tableview 单元格内的项目的交互吗?
我尝试过的失败:
- 确保在单元格对象上禁用可访问性
- 确保在标签对象上启用了可访问性
- 尝试了标签的各种特征组合
- 确保标签上启用了用户交互

想法?

【问题讨论】:

    标签: iphone ios uitableview accessibility voiceover


    【解决方案1】:

    找到答案

    我需要实现以下方法

    - (NSInteger)accessibilityElementCount;
    - (id)accessibilityElementAtIndex:(NSInteger)index;
    - (NSInteger)indexOfAccessibilityElement:(id)element;
    

    【讨论】:

    • 我们如何实现它们?我需要为具有自定义标签和 UIImageView 的 tableViewCell 实现配音,但它从不选择自定义标签。
    最近更新 更多