直接上添加 header 的代码吧:

如图,绿色部分为header,点击第一个不会触发cell的事件,但是点击第二个和之后的header会触发当前组第一个cell的点击事件,望大神们看看到底哪里出了问题,谢谢(实在是没分数了,仅有20分,请包涵)
func tableView(tableView: UITableView, viewForHeaderInSection section: Int) -> UIView?{
let cellID = "headerCell"
var headerCell = tableView.dequeueReusableCellWithIdentifier(cellID)
as? HeaderCell
headerCell?.backgroundColor = UIColor.greenColor()
if(headerCell == nil){
headerCell = HeaderCell(style: UITableViewCellStyle.Subtitle, reuseIdentifier: cellID)
}
switch section {
case 0:
headerCell!.headerLabel.text = "模式"
break
case 1:
headerCell!.headerLabel.text = "风速"
break
default:
headerCell!.headerLabel.text = "other"
break
}
return headerCell!
}

如图,绿色部分为header,点击第一个不会触发cell的事件,但是点击第二个和之后的header会触发当前组第一个cell的点击事件,望大神们看看到底哪里出了问题,谢谢(实在是没分数了,仅有20分,请包涵)