我有一个分组表我正在尝试添加一个footerview。但是,当我执行我的代码时,它会在每个部分之间添加一个灰色条,并将视觉样式从分组表外观更改为普通的UITableView。
如何在每个部分之间添加footerview?这是我的代码(在init方法中)
UIView *footerView = [[UIView alloc] initWithFrame:CGRectMake(0,0,320,500)];
SubmitButton *submitButton;
submitButton = [[SubmitButton alloc] init];
[submitButton setTitle:NSLocalizedString(@"BUTTON_TITLE_SEARCH", nil) forState:UIControlStateNormal];
submitButton.frame=CGRectMake(0,10,self.tableView.frame.size.width,50);
submitButton.autoresizingMask = UIViewAutoresizingFlexibleWidth;
[footerView addSubview:submitButton];
self.tableView.tableFooterView = footerView;
答案 0 :(得分:0)
使用委托方法中的节号来确定这是否确实是最后一节
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section;
{
if (section == 5){
format section.....
} else {
return nil;
}
}
我使用数字5作为表格最后一部分的示例。如果您不想要偏移量
,还需要将其他部分的高度设置为0 - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
if (section == 5) {
return 100;
} else {
return 0;
}
}