用 TableView 的代理方法添加的header点击第一个不触发事件,但是点击第二个header触发了第二组第一行的点击事件

来源:互联网 发布:mac上的三维软件 编辑:程序博客网 时间:2024/05/16 05:46
直接上添加 header 的代码吧:

    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分,请包涵)
0 0
原创粉丝点击