UIATableView始终命名为“空列表”

时间:2011-06-16 19:03:48

标签: iphone objective-c uitableview ios-ui-automation

我正在尝试在iPhone上设置一些UIAutomation测试。每当我在主窗口上执行logElementTree()时,我的所有UIATableView元素都具有名称“Empty list”。我已经尝试在相应的XIB文件中设置名称,但是一旦加载了数据,名称就会再次设置为“清空列表”。以下是调用logElementTree()的输出示例:

 4) UIATableView [name:Empty list value:rows 1 to 1 of 1 rect:{{x:0, y:64}, {width:320, height:416}}]
 5) UIATableCell [name:OfferCardTableViewCell value:(null) rect:{{x:0, y:160}, {width:320, height:416}}]
 6) UIAWebView [name:(null) value:(null) rect:{{x:0, y:160}, {width:320, height:418}}]
 6) UIAWebView [name:(null) value:(null) rect:{{x:320, y:160}, {width:320, height:418}}]
 6) UIAWebView [name:(null) value:(null) rect:{{x:640, y:160}, {width:320, height:418}}]

如您所见,表格视图不为空。有谁知道如何确保UIATableView元素的名称不是“空列表?”是否有代表,我没有在某处实施?

2 个答案:

答案 0 :(得分:1)

您想为UITableView设置accessibilityLabel。至少在Xcode 4中,您无法在Interface Builder中设置此属性 - 因此您必须以编程方式执行此操作。

答案 1 :(得分:1)

  

元素名称源自基础视图的辅助功能属性。如果指定了标识符属性字符串,则将该字符串用作名称;否则,label属性字符串用作名称。与标签方法形成对比。

不要使用辅助功能标签来标识元素,使用辅助功能标识符。

在界面构建器中,可以使用运行时属性设置标识符:

打开Identity Inspector - User Defined Runtime Attributes

Key Path: accessibilityIdentifier
Type: String
Value: <your identifier>