iOS日志-tableHeaderView/tableFoote
2018-08-22 本文已影响689人
石显军
- (void)_loadTableView
{
self.tableview.tableHeaderView = self.tableHeaderView;
self.tableview.tableFooterView = self.tableFooterView;
[self.tableview registerNib:UICellMineItemNext.dh_loadNib
forCellReuseIdentifier:UICellMineItemNext.dh_className];
}
#pragma mark - Getter
- (UITableHeaderViewMine *)tableHeaderView
{
if (_tableHeaderView == nil) {
_tableHeaderView = [[NSBundle mainBundle] loadNibNamed:@"UITableHeaderViewMine" owner:self options:nil].lastObject;
_tableHeaderView.delegate = self;
}
return _tableHeaderView;
}
- (UITableFooterViewMine *)tableFooterView
{
if (_tableFooterView == nil) {
_tableFooterView = [[NSBundle mainBundle] loadNibNamed:@"UITableFooterViewMine" owner:self options:nil].lastObject;
kWeakself
_tableFooterView.didChickFooterCallback = ^{
[weakself chickLogout];
};
}
return _tableFooterView;
}
image.png
下方高度明显不正确 tableFooterView 无法直接适应
解决方法:在header和footer 外层再套一层view 用来适配高度
#pragma mark - Getter
- (UIView *)tableHeaderView
{
if (_tableHeaderView == nil) {
_tableHeaderView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 200)];
UITableHeaderViewMine *contentView = [[NSBundle mainBundle] loadNibNamed:@"UITableHeaderViewMine" owner:self options:nil].lastObject;
contentView.delegate = self;
[_tableHeaderView addSubview:contentView];
[contentView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.mas_equalTo(_tableHeaderView);
}];
}
return _tableHeaderView;
}
- (UIView *)tableFooterView
{
if (_tableFooterView == nil) {
_tableFooterView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 60)];
UITableFooterViewMine *contentView = [[NSBundle mainBundle] loadNibNamed:@"UITableFooterViewMine" owner:self options:nil].lastObject;
kWeakself
contentView.didChickFooterCallback = ^{
[weakself chickLogout];
};
[_tableFooterView addSubview:contentView];
[contentView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.mas_equalTo(_tableFooterView);
}];
}
return _tableFooterView;
}
image.png