如何为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协议参考在accessibilityLabel下有一条注释,内容为:
First, UIAccessibility Protocol Reference has a note under accessibilityLabel that says:
如果您提供要在UISegmentedControl中显示的UIImage对象,可以在每个图像上设置此属性,以确保可以正确访问分段。
"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对象上的accessibilityLabel,并能够使用它通过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