UITableView设置设置section head高度

2017-11-16  本文已影响0人  凡凡_c009

今天在使用swift中设置UITableView的section head的高度时第一个section总是不对。

方法是

//        tableView.estimatedSectionFooterHeight = 0

//        tableView.estimatedSectionHeaderHeight = 0

设置代理方法

// func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {

//        return 10;

//    }

//

//    func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {

//        return 0.01;

//    }

解决方法:以上代码全部注释掉,特别是委托方法必须注释

添加如下代码

tableView.tableHeaderView = UIView.init(frame: CGRect(x: 0, y: 0, width: 0, height: 0.1))  这一行的高度必须设置

tableView.sectionHeaderHeight = 10;

tableView.sectionFooterHeight = 0.01;

上一篇 下一篇

猜你喜欢

热点阅读