UIView
有一个
UITableView
我已经为
UIView公司
以及
. 但是,我只能查询
UIView公司
在我的UITests上,表视图根本不显示。我还设置了
isAccessibilityElement
到
true
.
public lazy var tableView: UITableView = {
let tableView = UITableView()
tableView.dataSource = self
tableView.delegate = self
tableView.translatesAutoresizingMaskIntoConstraints = false
tableView.register(UITableViewCell.self, forCellReuseIdentifier: "cell")
return tableView
}()
// MARK: - Initialization
override init(frame: CGRect) {
super.init(frame: .zero)
commonInit()
self.layer.borderColor = UIColor.lightGray.cgColor
self.layer.borderWidth = 1
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
commonInit()
}
// MARK: - Private Methods
private func commonInit() {
isAccessibilityElement = true
accessibilityLabel = "Filter View"
tableView.isAccessibilityElement = true
tableView.accessibilityLabel = "Filter View Table"
tableView.accessibilityIdentifier = "Filter View Table"
addSubview(tableView)
addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "H:|-0-[tableView]-0-|", options: .alignAllLeft, metrics: nil, views: [ "tableView": tableView ]))
addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "V:|-0-[tableView]-0-|", options: .alignAllLeft, metrics: nil, views: [ "tableView": tableView ]))
}
let filterView = app.otherElements["Filter View"] // Custom View
XCTAssertTrue(filterView.exists)
let filterTableView = filterView.otherElements["Filter View Table"] // Table View as Custom View's subview
XCTAssertTrue(filterTableView.exists)