如何为 UISegmentedControl 的特定部分设置可访问性标签? [英] How do I set the accessibility label for a particular segment of a UISegmentedControl?

查看:27
本文介绍了如何为 UISegmentedControl 的特定部分设置可访问性标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们使用 KIF 进行功能测试,它使用元素的可访问性标签来确定向何处发送事件.我目前正在尝试测试 UISegmentedControl 的行为,但为此我需要为控件的不同部分设置不同的辅助功能标签.如何为特定细分设置可访问性标签?

We use KIF for our functional testing, and it uses the accessibility label of elements to determine where to send events. I'm currently trying to test the behaviour of a UISegmentedControl, but in order to do so I need to set different accessibility labels for the different segments of the control. How do I set the accessibility label for a particular segment?

推荐答案

我自己刚刚开始使用 KIF,所以我还没有测试过这个,但它可能值得一试.我相信我很快就会遇到同样的问题,所以我很想知道它是否有效.

I'm just getting started with KIF myself, so I haven't tested this, but it may be worth a try. I'm sure I'll have the same issue soon, so I'd be interested to hear if it works.

首先,UIAccessibility Protocol Reference 在accessibilityLabel 下有一个注释说:

First, UIAccessibility Protocol Reference has a note under accessibilityLabel that says:

如果您提供 UIImage 对象以在 UISegmentedControl 中显示,您可以在每个图像上设置此属性以确保可以正确访问这些段."

"If you supply UIImage objects to display in a UISegmentedControl, you can set this property on each image to ensure that the segments are properly accessible."

所以,我想知道您是否也可以在每个 NSString 对象上设置可访问性标签,并能够使用它来使用 KIF 访问每个段.首先,您可以尝试创建几个字符串,设置它们的可访问性标签,并使用 [[UISegmentedControl alloc] initWithItems:myStringArray];填充它.

So, I'm wondering if you could set the accessibilityLabel on each NSString object as well and be able to use that to access each segment with KIF. As a start, you could try creating a couple of strings, setting their accessibility labels, and using [[UISegmentedControl alloc] initWithItems:myStringArray]; to populate it.

请向我们通报您的进展情况.我想听听这是怎么回事

Please update us on your progress. I'd like to hear how this goes

这篇关于如何为 UISegmentedControl 的特定部分设置可访问性标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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