一刘莹、統(tǒng)一設(shè)置tableview的頭部和尾部的高度
33.png
// 設(shè)置頭部間距
self.tableView.sectionHeaderHeight = 0;
self.tableView.sectionFooterHeight = ZSCommonMargin;
問題:設(shè)置完成后株茶,頭行上面的間距比較大
55.png
解決方法如下:
- 先調(diào)用這個方法洽胶,計算cell的frame
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{ UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
ZSLog(@"%@",NSStringFromCGRect(cell.frame));
}
11.png
2.由此可知y值為35蛤奥。通過contentInset(內(nèi)邊距)進行設(shè)置佳镜。
// 設(shè)置內(nèi)邊距(-25代表:所有內(nèi)容往上移動25)
self.tableView.contentInset = UIEdgeInsetsMake(ZSCommonMargin - 35, 0, 0, 0);
最終效果圖:
7.png
二、分別設(shè)置不同的頭部和尾部的高度
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
if (section == 0) return 10;
if (section == 1) return 20;
}
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
if (section == 0) return 10;
if (section == 1) return 20;
}
*設(shè)置頭部凡桥、尾部的內(nèi)容
44.png
其它正在整理中