在UI测试中,我可以使用此代码获取第一个单元格:
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT DISTINCT ?s ?pLabel ?oLabel ?o WHERE {
?s ?p ?o.
VALUES ?s {<http://dbpedia.org/resource/Leipzig> <http://dbpedia.org/resource/Dresden>}
?p rdfs:label ?pLabel .
?o rdfs:label ?oLabel .
FILTER(LANG(?pLabel) = "" || LANGMATCHES(LANG(?pLabel), "en"))
FILTER(LANG(?oLabel) = "" || LANGMATCHES(LANG(?oLabel), "en"))
}
如何检查该单元格是否包含imageview?
答案 0 :(得分:3)
public func hasImageViewInside(_ cell: UITableViewCell) -> Bool {
for child in cell.subviews {
if let _ = child as? UIImageView {
return true
}
}
return false
}
答案 1 :(得分:2)
for viw in cell.contentView.subviews {
if ((viw as? UIImageView) != nil) {
print("123")
}
}
答案 2 :(得分:1)
for case let imageView as UIImageView in cell.contentView.subviews {
if imageView.tag == 1001 {
imageView.image = UIImage(named: "myCustomImage")
}
}
//OR Altervnatively
cell.contentView.subviews.flatMap { $0 as? UIImageView }.forEach { imageView in
if imageView.tag == 1001 {
imageView.image = UIImage(named: "myCustomImage")
}
}
答案 3 :(得分:1)