iOS中的setAccessibilityLabel和accessibilityIdentifier有什么区别? [英] What's the difference between setAccessibilityLabel and accessibilityIdentifier in ios?

查看:118
本文介绍了iOS中的setAccessibilityLabel和accessibilityIdentifier有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在遍历我们的代码库,并在所有按钮和文本字段上设置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问题解释了不同之处:

鉴于accessibilityLabel是可访问性屏幕阅读器实际使用的朝外字符串(应本地化为设备用户的语言),Apple现在提供了一个专门用于替代属性(iOS 5+)用于UI自动化

这篇关于iOS中的setAccessibilityLabel和accessibilityIdentifier有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆