问题描述
我一直在遍历我们的代码库,并在所有按钮和文本字段上设置accessibilityIdentifier属性,以便可以使用UIAutomation访问它们.在执行此操作时,我遇到了一些已经存在的代码.
I've been going through our code base and setting the accessibilityIdentifier property on all of our buttons and text fields so that I can access them using UIAutomation. While doing this, I came across some code that was already in place.
[_goodButton setAccessibilityLabel:@"off"];
我找不到有关这两种方法之间的区别的任何文档.看起来他们在做同样的事情.有人知道吗?我发现将这个标签也设置为"off"也很奇怪.
I can't find any documentation on what the differences are between these two methods. It looks like they do the same thing. Does anyone know? I find it peculiar that this label is set to "off" as well.
推荐答案
您应该使用.
Instead of using accessibilityLabel
(see below) you should use accessibilityIdentifier
.
此 github问题解释了不同之处:
这篇关于iOS中的setAccessibilityLabel和accessibilityIdentifier有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!