我知道如何在表视图中更改节标题的高度.但我无法找到任何解决方案来更改第一部分之前的默认间距.
现在我有这个代码:
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
if (section == 0){
return 0;
}
return 10;
}
Run Code Online (Sandbox Code Playgroud)

我有一个UITableView,显示当月的费用(见截图):
我的问题是空部分的标题.有没有办法隐藏它们?数据从coredata加载.
这是生成标题标题的代码:
TitleForHeader
-(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{
if ([tableView.dataSource tableView:tableView numberOfRowsInSection:section] == 0) {
return nil;
} else {
NSDate *today = [NSDate date ];
int todayInt = [dataHandler getDayNumber:today].intValue;
NSDate *date = [NSDate dateWithTimeIntervalSinceNow:(-(todayInt-section-1)*60*60*24)];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setLocale:[[NSLocale alloc] initWithLocaleIdentifier:[[NSLocale preferredLanguages] objectAtIndex:0]]];
[dateFormatter setTimeStyle:NSDateFormatterNoStyle];
[dateFormatter setDateStyle:NSDateFormatterMediumStyle];
NSString *formattedDateString = [dateFormatter stringFromDate:date];
return formattedDateString;}
}
Run Code Online (Sandbox Code Playgroud)
ViewForHeader
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
if ([tableView.dataSource tableView:tableView numberOfRowsInSection:section] == 0) {
return nil;
} else {
UIView *headerView = …Run Code Online (Sandbox Code Playgroud) 我有一个有3个部分的UITableView.他们每个都有一个我使用viewForFooterInSection添加的页脚.我遇到的问题是,当我向下滚动桌面视图时,页脚会粘到屏幕的底部,而不会像其他单元格那样滚动.有没有人知道如何制作它,所以页脚几乎就像一个单元格,并与表格的其余部分一起滚动?谢谢!