如何在xcode4的界面构建器中为视图设置辅助功能标签? [英] How do I set the accessibility label for a view in xcode4's interface builder?
问题描述
我希望使用 KIF 为我们的iphone应用编写功能测试。它使用辅助功能标签来识别它正在测试的UI项目。如何在xcode4的界面构建器中为视图设置辅助功能标签?
I'm hoping to use KIF to write functional tests for our iphone app. It uses "accessibility labels" to identify the UI items it's testing. How do I set the accessibility label for a view in xcode4's interface builder?
推荐答案
要以编程方式设置变量,可以使用其属性像这样:
To set the variable programmatically you can use its property like this:
UIButton *someButton = [[UIButton alloc] init];
someButton.titleLabel.text = @"Your Button's Text";
someButton.accessibilityLabel = @"SomeNSString";
在InterfaceBuilder中 - 内置于XCode 4中 - - 您只需选择要具有辅助功能标签的UI项目。 实用程序窗格中的身份检查器提供了一个文本字段,您可以在其中输入所需的任何标签文本。
In the InterfaceBuilder -- built into XCode 4 -- you just have to select the UI item you want to have an accessibility label. The "Identity Inspector", in the "Utility"-pane, offers a textfield where you can enter any label-text you want.
这篇关于如何在xcode4的界面构建器中为视图设置辅助功能标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!