我想要以下内容:
xpath=//tr[//td[@class='ref'][contains(text(),'LDE')]][//td[@class='from']/following-sibling::td[1][contains(text(),'2014')]]//input
什么是替代或最简单的方法呢?
修改
我是否也可以指定章节号:即 -
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("NewsCell", forIndexPath: indexPath) as! UITableViewCell
if indexPath == 3{
cell.height = "50dp"
}
return cell
}
答案 0 :(得分:22)
我建议使用 heightForRowAtIndexPath 功能。 TableView将调用此函数来确定特定索引路径的行高。
示例代码:
func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
if indexPath.section == SECTION_INDEX {
return 60
} else {
return UITableViewAutomaticDimension
}
}
斯威夫特4:
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
if indexPath.section == SECTION_INDEX {
return 60
} else {
return UITableViewAutomaticDimension
}
}
一点解释: indexPath有两个属性:section和row。通过检查这两个属性,您可以创建自己的控制流来确定每个单元格的高度。
如果返回60,则表示您希望单元格的高度为60磅。如果您返回UITableViewAutomaticDimension,您希望系统为您决定最佳高度(在这种情况下,您最好为故事板中的单元格设置autolayout)。
我还建议你在iTunes U上学习斯坦福课程CS193p,这对你有很大的帮助:)。
答案 1 :(得分:10)
最简单的方法是覆盖heightForRowAtIndexPath
override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
let section = indexPath.section
let row = indexPath.row
if section == 0 && row == 2{
return 50.0
}
return 22.0
}
答案 2 :(得分:4)
func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat{
if indexPath.section == 5
{
if indexPath.row == 3
{
return 150.0
}
}
return 200.0
}