在我的表视图中,有4个部分,第一部分有3行,第二部分有2行,第三部分有2行,第四部分有1行.
当按下时如何引用这些行?这是我到目前为止使用的代码.请帮忙
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
println("\(indexPath)")
switch indexPath {
case 0.1, 0.2, 0.3:
println("Row 1, 2, or 3 in section 1")
case 1.1:
println("Row 1 in section 2")
case 1.2:
println("Row 2 in section 2")
case 2.2:
println("Row 2 in section 3")
case 3.1:
println("Row 1 in section 4")
default:
println("Default")
}
}
Run Code Online (Sandbox Code Playgroud)