gpt4 book ai didi

ios - UI 测试 Xcode 7-无法访问 subview 中的元素

转载 作者:IT王子 更新时间:2023-10-29 08:08:48 26 4
gpt4 key购买 nike

我正在尝试访问 subview 中的元素,但我发现这是不可能的。

层次结构是:

View Controller :

  • 查看
    • 临时 View
    • 用户进入 View
      • 已输入邮政编码

我想访问 zipCodeEntered 文本字段。我有一个名为“zipCodeEntered”的辅助功能标签。

当我尝试记录自动化时,它只注册了 super View “userEnterView”,而不是我可以点击的实际文本字段。

我打印“app.otherElements[SUPER_VIEW_NAME].debugDescription”以查看该层次结构中有哪些元素,但没有打印出来。

关于为什么我不能访问这些元素/我如何访问它们有什么想法吗? enter image description here

最佳答案

subview 不可访问,因为父 View 不是容器 View 。来自 Making Your iOS App Accessible 部分来自辅助功能编程指南:

From the perspective of accessibility, a custom view is either an individual view or a container view. An individual view does not contain any other views that need to be accessible.

A container view, on the other hand, contains other elements with which users can interact.

要使 subview 可访问,父 View 应通过从 -isAccessibilityElement 返回 NO 并实现 UIAccessibilityContainer 的方法来告诉 UIAccessibility 它是一个可访问容器 协议(protocol)。

关于ios - UI 测试 Xcode 7-无法访问 subview 中的元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32801267/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com