有一个单元格包含一个Collection View。我已使用
在集合视图中设置了单元格cell.accessibilityLabel = @"daren_shangjia_0001_add_new_photo_album";
然后在XCTest,我做
print(app.debugDescription);
我没有看到我提供的accessibilityLabel。
Element subtree:
→Application 0x608000367200: {{0.0, 0.0}, {414.0, 736.0}}, label: '纳豆行'
Window 0x608000365e80: Main Window, {{0.0, 0.0}, {414.0, 736.0}}
Other 0x608000365880: traits: 8589934592, {{0.0, 0.0}, {414.0, 736.0}}
Other 0x608000365b80: traits: 8589934592, {{0.0, 0.0}, {414.0, 736.0}}
Other 0x608000365700: traits: 8589934592, {{0.0, 0.0}, {414.0, 736.0}}
Other 0x608000364d40: traits: 8589934592, {{0.0, 0.0}, {414.0, 736.0}}
Other 0x608000364680: traits: 8589934592, {{0.0, 0.0}, {414.0, 736.0}}
Other 0x608000364740: traits: 8589934592, {{0.0, 0.0}, {414.0, 736.0}}
Other 0x608000364800: traits: 8589934592, {{0.0, 0.0}, {414.0, 736.0}}
NavigationBar 0x6080003648c0: traits: 35192962023424, {{0.0, 20.0}, {414.0, 44.0}}, identifier: '140'
Button 0x608000364980: traits: 8589934593, {{20.0, 31.0}, {20.7, 20.5}}, label: 'da ren list backBtn'
StaticText 0x608000365f40: traits: 8590000192, {{192.0, 28.0}, {30.0, 27.0}}, label: '140'
Button 0x608000366000: traits: 8589934593, {{360.7, 25.0}, {33.3, 33.1}}, label: 'denglu 0010 you ke register'
Other 0x608000366240: traits: 8589934592, {{0.0, 0.0}, {414.0, 736.0}}
Other 0x6000003660c0: traits: 8589934592, {{0.0, 0.0}, {414.0, 736.0}}
Other 0x600000365e80: traits: 8589934592, {{0.0, 0.0}, {414.0, 736.0}}
Table 0x600000365dc0: traits: 35192962023424, {{0.0, 0.0}, {414.0, 680.8}}
Image 0x608000366a80: traits: 8589934596, {{0.0, 64.0}, {414.0, 219.6}}
Image 0x608000366cc0: traits: 8589934596, {{168.4, 135.2}, {77.3, 77.3}}
Button 0x608000367080: traits: 8589934593, {{151.8, 118.6}, {110.4, 110.4}}
Image 0x6080003672c0: traits: 8589934596, {{245.2, 195.3}, {16.6, 16.6}}, identifier: 'da_ren_list_girl'
答案 0 :(得分:3)
要访问容器视图中的视图,必须确保无法访问容器视图。在您的情况下,我认为这是表视图单元格。
let cell = UITableViewCell!
cell.isAccessibilityElement = false
为了降低辅助功能用户的复杂性,屏幕的任何部分最多只能有一个可访问的视图。单元格通常包含可以概括为单个实体的信息,例如,表示包括文本的项目和具有选择它的选项的图片。由于您已决定使用相当复杂的单元格,因此需要更改其默认行为,以允许Accessibility用户更细粒度地访问单元格的内容。它不能再在表视图单元级别进行汇总。因此,解释屏幕上的内容的工作必须传递给视图层次结构中较低的元素。
要进一步了解此概念,请尝试在启用VoiceOver的情况下使用您的应用,并使用三指三指点按来切换屏幕。
答案 1 :(得分:0)
我和你有同样的问题。希望这段代码可以帮到你。
// Get the first Cell and don't forget to set id for your tableview
let tableCellContainer = app.tables["HomeTableView"].cells.element(boundBy: 1)
// Get collection cell which is has the text label inside is 'Brazil'
let cell = tableCellContainer.staticTexts["Brazil"]
cell.tap()
XCTAssert(cell.exists)
答案 2 :(得分:0)
“ tableView”-TableView可访问性标识符
“ tableViewCell”-包含CollectionView的TableViewCell
“ daren_shangjia_0001_add_new_photo_album”-馆藏视图单元格可访问性标识符
f, (ax1, ax2) = plt.subplots(nrows=1, ncols=2, figsize=(12,3), dpi=90)