问题描述
在我的 SwiftUI 应用中,我有以下 TextField
在 Xcode13 / iOS 15 之前运行良好:
TextField("Blah blah blah",text: $currentText,onEditingChanged: { isEditing in
if !isEditing {
// Do the thing
}
},onCommit: {
})
.accessibility(identifier: "someIdentifier")
.keyboardType(.alphabet)
.padding()
.foregroundColor(.primary)
.disableAutocorrection(true)
.textFieldStyle(RoundedBorderTextFieldStyle())
还有一个与此 TextField
交互的 UI 测试。但是,它无法再通过我从 iOS 13 开始使用的 TextField
访问 Accessibility Identifier
。
当 UI 测试到达查询字段的点时,我可以运行此查找并获得以下输出:
(lldb) po app.textFields
t = 547.11s Requesting snapshot of accessibility hierarchy for app with pid 1234
t = 547.48s Find: Descendants matching type TextField
t = 547.48s Requesting snapshot of accessibility hierarchy for app with pid 1234
t = 547.50s Find: Descendants matching type TextField
t = 547.50s Requesting snapshot of accessibility hierarchy for app with pid 1234
Find: Target Application 'com.company.app'
Output: {
Application,pid: 1234,label: 'Awesomest App Ever'
}
↪︎Find: Descendants matching type TextField
Output: {
TextField,{{16.0,165.0},{286.7,34.0}},placeholderValue: 'Blah blah blah'
}
查看文档,我还没有发现任何表明标识符行为发生变化的内容,但我可能遗漏了一些东西。
关于如何使用标识符(内容更改、本地化等)定位字段的任何想法?
更新
如果没有明显的原因,我只会提交雷达并交叉手指。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)