如何在 xcode4 的界面生成器中设置视图的辅助功能标签?

发布于 2024-12-02 07:21:38 字数 157 浏览 7 评论 0原文

我希望使用 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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

不乱于心 2024-12-09 07:21:38

要以编程方式设置变量,您可以像这样使用它的属性:

UIButton *someButton = [[UIButton alloc] init];
someButton.titleLabel.text = @"Your Button's Text";
someButton.accessibilityLabel = @"SomeNSString";

在 InterfaceBuilder(内置于 XCode 4)中,您只需选择想要具有辅助功能标签的 UI 项目。 “实用程序”窗格中的“身份检查器”提供了一个文本字段,您可以在其中输入所需的任何标签文本。

在此处输入图像描述

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";

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.

enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文